Unit 2 · Programming 1 · Lesson 2.10 · Paired Lab

Lab: Mad Libs

Your first lab with a partner. Everything from Week 2 — inputs, strings, methods, f-strings — in one program that’s actually fun to run on your friends.

Big Idea 1 — Creative DevelopmentDriver + navigator

Before this lab

No reading — pair up and build. Keep 2.7 (f-strings) and 2.4 (input) open. Decide who drives first.

1

Where We Are

People→ Bits→ Programs→ Internet→ Security→ Big Data→ Impact

End of Week 2 in Programs. You put the whole week together and practice the collaboration process from 2.9 — the exact muscles the Create PT grades.

2

The Brief

Build a Mad Libs generator in Python: collect silly words from the user, then drop them into a story and print it. With a partner, using the driver/navigator method.

Requirements

□ A purpose sentence comment at the top.

□ At least four inputs (e.g. a noun, a verb, an adjective, a name).

□ Store each in a well-named variable.

□ Assemble the story with an f-string (2.7), not a pile of +.

□ Use at least one string method — e.g. .upper() a word for emphasis, or .capitalize() a name.

□ Print the finished story cleanly.

3

The Model

Copy the shape, not the story — then write your own, funnier one:

Python — a Mad Libs skeleton

# This program builds a silly story from user
# words so that two friends can make each other laugh.
name = input("A name? ")
adj = input("An adjective? ")
animal = input("An animal? ")
verb = input("A verb? ")
story = f"{name} met a {adj} {animal} that could {verb}!"
print(story.upper())

What each part is doing

# purpose: what + why
#
# four inputs, each stored
# in a clearly named
# variable
#
# f-string drops them into the story
# a string method for flair

Hover or tap a line to light its twin. Your job: keep this structure, invent a better story, and add a fifth input for the Challenge tier.

4

Try It — See It Run

Fill the blanks and generate the story the skeleton above would print. This is exactly what your program should do — use it to check your output looks right.

press Generate
5

What You Turn In

Three things, per the 2.9 process

□ The working program (runs, four+ inputs, f-string output).

□ Your purpose sentence at the top of the file.

□ One sentence about a bug you fixed — and name its type (syntax, run-time, or logic, from 2.8). Every pair hits at least one; that’s the point.

That bug sentence is small but it’s real Create PT practice: describing your development process in precise words is worth points in May.

6

How to Pair

Driver and navigator — swap every 10 minutes

Driver has the keyboard and types. Navigator reads along, catches typos and logic slips, and thinks about the next step. Neither role is “the helper” — the navigator is doing half the programming, out loud.

When the timer hits ten minutes, swap, even mid-line. Both of you must be able to explain every line by the end — if the navigator goes quiet, the method isn’t working. Talk the whole time.

7

Challenge Tier

If you finish early

Add a fifth and sixth input and a second paragraph so the story has a beginning and an end. Or: use a string method to auto-.capitalize() the name no matter how it’s typed, and .lower() the animal so “LLAMA” and “llama” both read cleanly. Small polish, real craft.

8

Connections

Uses all of Week 2 — inputs (2.4), strings and indexing (2.6), methods and f-strings (2.7), error-naming (2.8), and the paired process (2.9).
Builds the PT habit — purpose sentence plus a precise sentence about a bug you fixed is written-response practice.
Next in 2.11 — decisions. So far every program runs the same way every time; next week it starts making choices with if.
Returns in 2.17 — Mini-Project 2 (Quiz Bot) is this lab with conditionals and score-keeping added. Today’s pairing habits carry straight over.
← 2.9 How Software Gets Made