Chapters
Python114 chapters

Exercises

Dates

3 tasks. Write the code, press Check, and the page runs it against a real Python interpreter.

Exercise 1

Print the 14th of March 2026 formatted as day/month/year.

Python
from datetime import date
# print 14/03/2026
Exercise 2

Print how many days there are between the two dates.

Python
from datetime import date

start = date(2026, 3, 1)
end = date(2026, 3, 14)
# print the number of days
Exercise 3

Read the ISO date text into a date object and print its year.

Python
from datetime import date

text = "2026-03-14"
# print the year as a number