← All worksheets

Christmas countdown worksheet 🎄

A one-page guide, practice tasks and a 8-question quiz to go with the Christmas countdown video: dates, loops, conditions and f-strings.

Download the PDF Watch the video and run the code

Guide

1. import: borrow a tool

A module is a toolbox someone already built. We borrow only the part we need.

from datetime import date

2. A date is year, month, day

Save it in a variable so you can use it again.

today = date(2026, 12, 15)
christmas = date(today.year, 12, 25)

3. Compare dates with if

Dates can be compared with > and <. The indented line only runs when the answer is True.

if today > christmas:
    christmas = date(today.year + 1, 12, 25)

4. Subtract dates, then use .days

Subtracting gives a gap. Adding .days turns it into a plain whole number.

sleeps = (christmas - today).days
print(sleeps)           # 10

5. // and % for weeks and days

// divides and rounds down. % gives the remainder, what is left over.

print(sleeps // 7)      # 1 week
print(sleeps % 7)       # 3 days left over

6. strftime: date to text

strftime turns a date into text. The % codes choose which part.

christmas.strftime("%A")        # Friday
christmas.strftime("%a %d %b")   # Fri 25 Dec

7. A loop repeats

range(1, 25) gives 1 to 24. It stops just before the last number.

for day in range(1, 25):
    print(day)

8. if, elif, else

Python checks each one in turn and uses the first that is True.

if day < today.day:
    door = " X"
elif day == today.day:
    door = "[" + str(day) + "]"
else:
    door = f"{day:>2}"

9. f-strings and padding

An f in front of the quotes lets you put values inside { }. After the colon, > pads on the left and < pads on the right to a set width.

f"{day:>2}"      # ' 7'
f"{name:<16}"    # name padded to 16

10. end and one row at a time

end="" stops print jumping to a new line. day % 6 == 0 is True every sixth door, so we start a new row.

print(f"{door:>4}", end="")
if day % 6 == 0:
    print()

Try it yourself

  1. Change today to your birthday month and day. How many sleeps until it?
  2. Print how many full weeks and leftover days remain until Christmas.
  3. Change the advent calendar to 31 doors. What has to change in range()?
  4. Add "Twelfth Night" on 5 January to the EVENTS list.
  5. Challenge: print a countdown line for every day from today to Christmas Eve.

Quiz

  1. What does from datetime import date do?
    A. Prints today's date
    B. Borrows the date tool from the datetime module
    C. Deletes the date
    D. Makes a loop
    Answer: B. import borrows a ready-made tool so you can use it in your code.
  2. What does (christmas - today).days give you?
    A. Text such as 'Friday'
    B. A whole number of days
    C. A new date
    D. A list
    Answer: B. Subtracting two dates gives a gap, and .days turns it into a plain number.
  3. What is 10 // 7?
    A. 3
    B. 1.43
    C. 1
    D. 7
    Answer: C. // divides and rounds down, so 10 // 7 is 1.
  4. What is 10 % 7?
    A. 3
    B. 1
    C. 0
    D. 17
    Answer: A. % gives the remainder: 10 is one 7 and 3 left over.
  5. How many times does for day in range(1, 25) run?
    A. 25
    B. 23
    C. 24
    D. 1
    Answer: C. range stops just before 25, so it runs for 1 to 24, which is 24 times.
  6. In an if, elif, else chain, how many of the branches run?
    A. All of them
    B. Only the first one whose test is True
    C. Only the last one
    D. None
    Answer: B. Python checks in order and runs the first True branch, then skips the rest.
  7. What does f"{day:>2}" do?
    A. Pads the number to 2 characters wide, on the left
    B. Doubles the number
    C. Prints the word day
    D. Compares day with 2
    Answer: A. > pads on the left, so 7 becomes ' 7' and the columns line up.
  8. What does end="" do inside print?
    A. Stops the program
    B. Stops print starting a new line
    C. Prints an empty list
    D. Ends the loop
    Answer: B. By default print ends with a new line. end="" swaps that for nothing, so output stays on one line.

Start the free lessons More worksheets