What you'll build
Use the datetime box to answer a question that's tedious by hand: how many days until an application closes? Subtract one date from another and let Python count for you.
Requirements
The must-do parts. If any are missing, we'll ask you to take another pass.
- Import the date tool with
from datetime import dateat the top of the cell. - Build a deadline with
date(year, month, day)and get today's date withdate.today(). - Work out the gap by subtracting today from the deadline, then read the number of whole days with
.days. - Print a clear sentence, e.g.
73 days until the deadline.
Bonus, if you're feeling brave
- Wrap it in your own function
days_until(deadline)that takes a date and returns the number of days, so you can reuse it for several deadlines. - Keep a list of two or three deadlines and loop your function over all of them, printing a countdown for each.
Examples
What your program should look like when it runs. Lines starting with $ are typed by you; the rest is your program.
Example cell runs (the number depends on the day you run it)
73 days until the deadline.Where to start
Copy this scaffold into a new file. You don't have to use it — it's just a friendly nudge.
# Days-until-the-deadline countdown
from datetime import date
# TODO: set the application deadline as a date(year, month, day)
deadline = date(2026, 9, 1)
# TODO: get today's date with date.today()
# TODO: subtract today from the deadline, then read .days
# TODO: print a sentence like "73 days until the deadline."How we'll grade it
Four checks, four points. Three or above is passing — we'll ask you to revise anything we can't tick.
| Check | What we look for | Pt |
|---|---|---|
| It runs | Imports cleanly and prints a countdown sentence without errors. | 1 |
| Uses datetime | The deadline and today's date are real `date` objects, and the gap comes from subtracting them — not from arithmetic on plain numbers. | 1 |
| Reads the day count | The number of days is pulled out with `.days` from the subtraction, not guessed or hard-coded. | 1 |
| Reads well | The output is a clear, full sentence that names the number of days. | 1 |