Kids Coding

Project: Mad Libs

Ask for words, then fill a silly story. print, input, and strings together.

KidsBasicProject: Mad Libs

Fill a silly story

Mad Libs asks for words, then drops them into a story. You already have print, strings, and variables. That is the whole project.

The pieces

  • Pick a name, a place, and a food.
  • Join them into sentences.
  • Print the story.

A story (saved words)

name = "Sam"
place = "the moon"
food = "noodles"

print("Once, " + name + " went to " + place + ".")
print(name + " packed a lunch of " + food + ".")
print("It was a very strange day.")

On a computer, replace each saved word with input("A name: ") and friends can type their own.

Make it yours

Change the sentences. Add a fourth word. Print a title line first.

Real life

Making up a lunch-table story with friends.

Each friend drops in a word. The story changes. That is Mad Libs at the cafeteria.

Cafeteria story

friend = "Jun"
food = "noodles"
place = "the roof"
print(friend + " ate " + food)
print("then ran to " + place + ".")
print("The teacher was not happy.")

Change one word. Run it. That is how this idea shows up outside the lesson.

Try it

Exercise 1: Write a three-line story that uses animal and colour.

Show solution
animal = "fox"
colour = "teal"
print("A " + colour + " " + animal + " sat down.")
print("It wanted a snack.")
print("Then it ran home.")

FAQ: Project: Mad Libs

Common questions about this page.

What is StudyGrid Kids?

StudyGrid Kids is a free coding path for children: Basic, Intermediate, and Advanced. Lessons use Python in the browser. No account and no install.

Should I run project: mad libs examples locally for better learning?

Yes. Use the browser editor on StudyGrid for a quick check, then Download the example and run it on your computer. Local runs show real errors and the real toolchain, which is one of the fastest ways to learn project: mad libs in this Kids Coding Python lesson (Project: Mad Libs).

Which kids level should we start with?

Start at Basic if the child has never written code. Choose Intermediate if they can print, use variables, and write a simple if. Choose Advanced if they already use loops and lists.

Do kids need an account or an app?

No. Kids pages are public. Code runs in the Try Python editor at /try. We do not ask children for a name or an email.

What language do kids learn?

Python, with a first HTML page in Intermediate and Advanced. After Advanced, the main Python tutorial is the next step.

Is the kids coding track free?

Yes. The Kids home, the three levels, and the Python editor on StudyGrid (studygrid.in) are free.