Python Modules
💡
Exercise 41

Countdown 15 XP Easy

Ctrl+Enter Run Ctrl+S Save

The datetime module handles dates and times:

from datetime import datetime, date now = datetime.now() print(now) # 2026-03-08 14:30:00.123456 print(now.year) # 2026 print(now.month) # 3 print(now.day) # 8

You can calculate the difference between dates:

from datetime import date birthday = date(2026, 12, 25) today = date.today() delta = birthday - today print(f'{delta.days} days until birthday!')
📋 Instructions
Create a countdown to New Year's Day 2027! 1. Import `datetime` 2. Get today's date 3. Create a date for Jan 1, 2027 4. Calculate the difference 5. Print the countdown Since today's date changes, any valid output is accepted!
new_year = date(2027, 1, 1). today = date.today(). delta = new_year - today. Print delta.days.
⚠️ Try solving it yourself first — you'll learn more!
from datetime import datetime, date

now = datetime.now()
print(now)  # 2026-03-08 14:30:00.123456
print(now.year)   # 2026
print(now.month)  # 3
print(now.day)    # 8
main.py
Hi! I'm Rex 👋
Output
Ready. Press ▶ Run or Ctrl+Enter.