Python by Projects › Story Machine
Exercises: Story Machine
Make each program your own. Run your work often. When something breaks, read the final traceback line for a clue.
Exercise 1: Greeting-card printer
Print a title and a friendly message for someone. Use a separate print() instruction for each part. Add a comment that explains what your program makes.
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 2: Fix the missing quote
Run the broken snippet only when you are ready to read its error message. Find the line named at the end of the traceback. Fix the quote so the greeting can print.
How this is checked: Checked by comparing what your program prints with the expected output.
Answer format: one line
Exercise 3: Fix the mixed-up name
This program stops because a variable name changes spelling. Read the final traceback line. Make the names match, then change the message's words to your own.
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 4: Story remix with variables
Save a hero, a place, and a silly object in clearly named variables. Print a short story that reuses every variable. Use an f-string for part of the story.
Real program
The real program reads the hero, place, and silly object with input(...).
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 5: Interview bot
Ask the player for a name, a favorite snack, and a dream job. Save each reply in a clear variable. Use the replies in a cheerful f-string message.
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 6: Story Machine remix
Create a new Mad-Libs story. Collect a character, a place, an object, and an action with input(). Save each reply in a clear variable. Print a title with string concatenation. Print the story with f-strings. Add a comment that describes your remix.
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 7: Build a greeting with `+`
Change the value of name to your name. Print Hello, <name>! by joining exactly three pieces with +: the fixed greeting literal "Hello, ", the name variable, and the punctuation literal "!". Do not use an f-string.
Real program
The real program reads name with input(...), then joins exactly the same three pieces with +.
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Challenge
Try these when your core exercises are ready.
Challenge 1
Write a multi-paragraph story. Print an empty string literal between paragraphs to make a blank line. Reuse the same hero and place variables in every paragraph.
Real program
The real program reads hero and place with input(...).
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Challenge 2
Build an emoji-art title generator. Ask for an emoji and title words with input(). Save both replies. Use string concatenation or an f-string to place the emoji around the title.
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.