Session 3 starters: boxes and Mad Libs at three fill levels

This commit is contained in:
kenn 2026-09-24 09:14:47 -05:00
parent d7f41fbd99
commit d69f90cfb2
5 changed files with 149 additions and 0 deletions

View file

@ -6,3 +6,12 @@ fill levels, and crib sheets for the python class.
Students read this; they never push to it. A session's starter reaches a
student by being fanned out into their own `python` repo before class, so the
only command they run is `git pull`.
## Session 3 — Sep 25 · Variables
| File | Who |
|---|---|
| `boxes.py` | Everyone. Predict on paper first, then run. |
| `madlibs_fox.py` | Most help: 3 of 5 input lines written, fill 2. |
| `madlibs_owl.py` | Some help: story written, write the 5 input lines from comments. |
| `madlibs_bear.py` | Least help: write the inputs and the story. |

32
boxes.py Normal file
View file

@ -0,0 +1,32 @@
# BOXES
#
# Do NOT run this yet!
# First, guess what each program prints. Write your guesses on your paper.
# Then run it and check.
print("--- Program 1 ---")
pet = "cat"
print(pet)
print("--- Program 2 ---")
pet = "cat"
print("pet")
print("--- Program 3 ---")
pet = "cat"
pet = "dog"
print(pet)
print("--- Program 4 ---")
x = 5
x = 7
print(x)
print("--- Program 5 ---")
name = "Sam"
print("Hi, Sam " + name)

30
madlibs_bear.py Normal file
View file

@ -0,0 +1,30 @@
# MAD LIBS — Bear
#
# You write the questions AND the story.
#
# A box (variable) is made like this:
# name = input("Type a name: ")
#
# A story line uses boxes like this:
# print(f"One day, {name} went to the store.")
#
# Run it with the play button ▶ (top right).
# 1. Make at least 5 boxes. Ask for things like an animal, a food,
# a place, a silly word, a number.
# 2. Write your story. At least 4 lines. Use every box at least once.
# Use one box two times.
print()
print("THE END")
# BONUS 1: Ask for a number with int(input(...)).
# Do some maths with it inside the story, like {number * 100}.
# BONUS 2: Make the story ask a question in the middle, then keep going.

34
madlibs_fox.py Normal file
View file

@ -0,0 +1,34 @@
# MAD LIBS — Fox
#
# The story is at the bottom. It is already written.
# The story needs words. Each word goes in a box (a variable).
#
# 3 boxes are done for you. 2 are not.
# Find the ____ lines and finish them. Copy the ones that are done.
# If you see NameError: name '____' you missed a blank.
#
# Run it with the play button ▶ (top right).
name = input("Type a name: ")
animal = input("Type an animal: ")
food = input("Type a food: ")
place = ____ # Ask for a place. Copy a line above and change it.
silly_word = ____ # Ask for a silly word.
# ----- THE STORY -----
# The f means: fill in the boxes.
# {animal} means: open the box called animal and put its word here.
print()
print(f"One day, {name} found a giant {animal} in the {place}.")
print(f"The {animal} was eating {food}.")
print(f"It looked up and yelled, \"{silly_word}!\"")
print(f"So {name} shared the {food}, and they became best friends.")
print("THE END")
# BONUS 1: Add one more line to the story. Use one of your boxes in it.
# BONUS 2: Make a new box called color. Use it in the story.

44
madlibs_owl.py Normal file
View file

@ -0,0 +1,44 @@
# MAD LIBS — Owl
#
# The story is at the bottom. It is already written.
# It needs 5 boxes (variables). You make them.
#
# Here is how one box is made:
#
# name = input("Type a name: ")
#
# Run it with the play button ▶ (top right).
# 1. Make a box called name. Ask for a name.
name = input("Type a name: ")
# 2. Make a box called animal. Ask for an animal.
# 3. Make a box called food. Ask for a food.
# 4. Make a box called place. Ask for a place.
# 5. Make a box called silly_word. Ask for a silly word.
# ----- THE STORY -----
# The f means: fill in the boxes.
# {animal} means: open the box called animal and put its word here.
print()
print(f"One day, {name} found a giant {animal} in the {place}.")
print(f"The {animal} was eating {food}.")
print(f"It looked up and yelled, \"{silly_word}!\"")
print(f"So {name} shared the {food}, and they became best friends.")
print("THE END")
# BONUS 1: Add two more lines to the story. Use your boxes.
# BONUS 2: Ask for a number, like this:
# number = int(input("Type a number: "))
# Then use {number * 2} in the story. What happens?