Unit 2 · Programming 1 · Lesson 2.15 · Lab

Lab: Decision Day

Everything from Week 3 in one program: build a ticket-price calculator that reads the customer’s age and the day of the week, then charges the right price. All conditionals, no new syntax.

Big Idea 3 — Algorithms & ProgrammingLab · 10 points

Before this lab

No reading — build. Keep 2.13 (elif chains) and 2.14 (and / or) open in other tabs. You’ll use both today.

1

Where We Are

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

End of Week 3 in Programs. You put the whole week of decisions together into one working program — input, an elif chain, and (for the Challenge) a compound condition. This is also a Create PT rehearsal: a purpose, a decision, and a precise sentence about your process.

2

The Brief

Write a Python program that asks for a customer’s age and the day of the week, then prints the ticket price using these rules:

The price rules

□ Under 5: free ($0).

□ Ages 5–12 (child): $8.

□ Ages 13–64 (adult): $12.

□ 65 and up (senior): $9.

□ Tuesday is $2 off any price that isn’t already free.

Requirements

□ A purpose sentence comment at the top.

□ Read age with input() and convert with int() (2.4).

□ Use an elif chain for the age brackets — highest-priority conditions first.

□ Apply the Tuesday discount with a separate if.

□ Print the final price in a clear sentence with an f-string (2.7).

3

The Model

Copy the shape, not the numbers — then fill in the rules yourself:

Python — skeleton

# Prints a ticket price from age and day
# so the box office can charge correctly.
age = int(input("Age? "))
day = input("Day? ")
if age < 5:
    price = 0
elif age <= 12:
    price = 8
elif age <= 64:
    price = 12
else:
    price = 9
if day == "Tue" and price > 0:
    price = price - 2
print(f"Price: ${price}")

What each part is doing

# purpose: what + why
#
# age is a number → int()
# day stays text
# elif chain, highest
# priority (free) first
# child
#
# adult band
#
# everything left = senior
#
# compound condition:
# Tuesday AND not already free
# f-string output

Hover or tap a line to light its twin. Notice line 11: the discount uses an and so a free toddler ticket never goes to -$2. That guard is the kind of detail graders look for.

4

Try It — Check Your Output

Run your rules against this before you trust your code. Set an age and a day; it shows the price your program should print. If yours disagrees, you found a bug.

age = day =
Presets:
5

What You Turn In

Three things

□ The working program (reads age and day, prints the correct price).

□ Your purpose sentence at the top of the file.

□ One sentence naming a test you ran — an input you tried and the price you expected — and whether it matched. (“I tested age 4 on Tuesday and expected $0; it printed $0.”)

That test sentence is 2.16 arriving early: real programmers decide what the right answer is before running, then check. It’s also Create PT written-response practice.

6

How to Work

Solo or paired — either way, build the elif chain first

Get the four age bands working and printing a price before you add the Tuesday discount. A program that does one thing correctly beats one that half-does two. Test each band as you add it: an age in the middle, then the exact boundary (is 12 a child or an adult in your code?).

If you pair, swap driver and navigator every 10 minutes as in 2.10. Both of you must be able to explain why the discount uses and.

7

Challenge Tier

If you finish early — add input validation

Real box-office software can’t trust its input. Add a check at the top: if the age is negative or absurdly large (say over 120), print a clear error instead of a price. That’s a compound condition — if age < 0 or age > 120: — straight from 2.14.

Bigger challenge: swap the theme to a heat-index or BMI classifier — read two numbers and sort the result into safe/caution/danger bands with an elif chain. Same skill, different story.

8

Connections

Uses all of Week 3 — input (2.4), an elif chain (2.13), a compound condition (2.14), and f-string output (2.7).
Next in 2.16 — you’ll deliberately try to break this calculator with weird inputs, then write the tests that catch the breaks.
Returns in 2.17 — Mini-Project 2 (Quiz Bot) is this lab plus score-keeping and a written paragraph.
Returns on the exam — “what price does this program print for these inputs?” is an elif-chain trace, guaranteed points.
← 2.14 Logical Operators