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. 賛成 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 かつ ================.
実行ボタンをクリックして出力を確認してください。