Exercise 2 solution import calendar from datetime import date born = date(2024, 2, 29) def birthday_in(born, year): return date(year, born.month, min(born.day, calendar.monthrange(year, born.month)[1])) for year in range(2025, 2030): b = birthday_in(born, year) print(f"{year}: {b:%a %d %b %Y} leap={calendar.isleap(year)}") print("leap years 1896-1912:", [y for y in range(1896, 1913) if calendar.isleap(y)]) print("count 1900-2100 inclusive:", calendar.leapdays(1900, 2101)) Output (run, and exactly as shown): 2025: Fri 28 Feb 2025 leap=False 2026: Sat 28 Feb 2026 leap=False 2027: Sun 28 Feb 2027 leap=False 2028: Tue 29 Feb 2028 leap=True 2029: Wed 28 Feb 2029 leap=False leap years 1896-1912: [1896, 1904, 1908, 1912] count 1900-2100 inclusive: 49 Explanation: 29 February has to be mapped to a real date in non-leap years; this solution uses 28 February (some legal systems use 1 March, so the policy is a decision, not a fact of nature). 1900 is skipped because years divisible by 100 are leap years only when also divisible by 400, which is why 1900 and 2100 are not leap years. calendar.leapdays(y1, y2) counts leap years from y1 up to but not including y2, so the end value is 2101.