Project: Mad Libs
이 페이지는 최신 브라우저(SharedArrayBuffer 지원)가 필요합니다. Chrome, Edge, Firefox 또는 Safari를 최신 버전으로 업데이트해 주세요.
English
Project: Mad Libs
- In this project you build a small story machine.
- It asks for a few words, then puts them into a story.
- You use what you know:
input(), joining strings with+, and string methods.
English
What you will build
Mia
cat
pizza
The story of Mia
================
Mia has a pet CAT.
It eats pizza every day.
- The first three lines are what the user types. The rest is the story.

English
Step 1: collect the words
- Each
input()reads one line. Store each word in its own variable. - Join the words with
+, and put the spaces inside the quotes.
English
Step 2: change a word
.upper()gives a CAPITAL copy:"cat".upper()is"CAT".- Each
printadds one line to the story.
English
Step 3: a title with a line under it
len(text)counts the characters in a string."=" * 5repeats a string five times:=====.- So
"=" * len(title)draws a line exactly as long as the title.
English
title = "Hello"
print(title)
print("=" * len(title))
English
Now build it
- Three steps. Each task starts with your code from the step before.
- Press Run and type the words yourself, then press Check answer.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
Step 1: read a 열거하시오, then an animal, each with input(). Print one sentence. For the inputs Mia 및 cat, print Mia has a pet cat.
출력을 보려면 '실행'을 클릭하세요.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
Step 2: also read a 식품. Print two lines: the first sentence with the animal in CAPITALS, then It eats + the food + every day. 지지(For) Mia, cat 및 pizza: Mia has a pet CAT. 및 It eats pizza every day.
출력을 보려면 '실행'을 클릭하세요.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
Step 3: start the story with a title, The story of + the name, and underline it with = signs exactly as long as the title (use len). For Mia the first two lines are The story of Mia 및 ================.
출력을 보려면 '실행'을 클릭하세요.