Here are the teaching notes, the code, and a breakdown to help you guide your 13-year-old through building their first Python project.
Teacher Notes: Concepts to Explain First
Before writing the code, explain these three core concepts using simple analogies:
print()(How the computer talks): This tells the computer to display text on the screen. Whenever we want the computer to say something to us, we put the words inside the parentheses and quotes.- Variables (Digital boxes): Imagine a variable as a labeled box where we can store information. We can name the box whatever we want (like
nounoradjective), put a word inside it, and open the box later to use that word. input()(How the computer listens): This is how we ask the user a question. The computer will wait for the person to type something and press Enter. We usually take whatever they typed and put it straight into a variable (our digital box).
The Code: The Mad Libs Generator
You can have them type this directly into their Python editor (like Replit or IDLE). Modern Python uses something called f-strings (placing an f before the string), which is the easiest and cleanest way to mix variables and text.
Python
# The Mad Libs Generator
print("Welcome to the Mad Libs Generator!")
print("Answer the questions below to create a funny story.")
print("--------------------------------------------------")
# 1. Getting the words and storing them in variables
noun = input("Give me a noun (like a ninja, pizza, or spaceship): ")
adjective = input("Give me an adjective (like smelly, gigantic, or glowing): ")
verb = input("Give me a verb ending in 'ed' (like ran, exploded, or danced): ")
# 2. Building and printing the story using an f-string
print("\n--- Here is your story! ---")
# The 'f' lets us put our variables directly inside the sentence using curly brackets {}
print(f"One day, a {adjective} {noun} suddenly {verb} all the way to the moon!")
print("It was the strangest thing anyone had ever seen.")
Step-by-Step Guide for the Lesson
Step 1: Write the welcome message
Have them start by writing the print() statements at the top. Run the code immediately so they can see the computer “talk” to them. This provides instant gratification.
Step 2: Collect the words
Show them how to create a variable. Write noun = input("...") and explain that the computer will pause, wait for an answer, and then store that answer in the word noun. Have them do the same for adjective and verb.
Step 3: Write the story
Explain the magic of the f-string. Tell them: “If we just put a normal string, it will literally print the word ‘noun’. But if we put an ‘f’ in front of the quotes and wrap our variable in curly brackets {} , the computer knows to open the box and print what’s inside!”
Step 4: Test and break it
Run the code and put in silly words. Then, encourage them to “break” the code intentionally to see what happens. Remove a parenthesis or a quotation mark. Show them what a Syntax Error looks like so they aren’t afraid of red error text when they make natural mistakes later.
🌟 Bonus Challenge
Once they get the basic version working, challenge them to expand it! Ask them: “Can you make the story three sentences long and ask the user for a number, a famous person’s name, and an animal?” This forces them to practice creating new variables and adding them to the final story on their own.