Every morning the flight director asks the same question: how many days until launch? Rocket wants a program that answers it for any launch date anyone types in.
"It should also handle a launch that already happened," he says, "without saying minus ten days, which would be silly."
Raven lists the cases in her notebook: the future, today, and the past. "What do you notice?" she asks. "Three cases. That sounds like if, elif and else."
Nova shows a calendar with a fixed test date circled. "Interesting," she says. "Test with a date you choose first, so you can check the answer by hand. Then let the program use the real today."
Rocket writes a function with two parameters: the target and today.
# days_until.py
from datetime import date
def days_until(target, today):
"""Whole days from today to target. Negative if it has passed."""
return (target - today).days
year = int(input("Launch year: "))
month = int(input("Launch month (1 to 12): "))
day = int(input("Launch day: "))
launch = date(year, month, day)
today = date(2026, 6, 1) # test date: change to date.today() later
left = days_until(launch, today)
if left > 0:
print(f"{left} days until launch.")
elif left == 0:
print("Launch is today!")
else:
print(f"Launch was {-left} days ago.") With the test date of 1 June 2026, a launch on 20 July 2026 gives:
Launch year: 2026 Launch month (1 to 12): 7 Launch day: 20 49 days until launch.
And a launch on 30 May 2026, which is before the test date:
Launch year: 2026 Launch month (1 to 12): 5 Launch day: 30 Launch was 2 days ago.
A list of tuples can hold several events, each with a name and a date. One loop then runs the same function for every event.
# countdown_board.py
from datetime import date
def days_until(target, today):
return (target - today).days
today = date(2026, 6, 1) # test date
events = [
("Engine test", date(2026, 6, 8)),
("Crew photo", date(2026, 6, 20)),
("Launch", date(2026, 7, 20)),
]
for name, when in events:
print(f"{name}: {days_until(when, today)} days") Engine test: 7 days Crew photo: 19 days Launch: 49 days
| Statement | True or false? |
|---|---|
| One function can be called once for each item in a loop. | ? |
| date(2026, 13, 1) gives a ValueError. | ? |
| days_until can return a negative number. | ? |
| The output says 1 days because Python fixes grammar. | ? |
You tested with a fixed date, then switched to the real one, just like professional programmers do. Tomorrow is a Crew Quest.