#132 · Simulation · Advanced · 120 XP · about 25 min
Write day_of_week(year, month, day) that returns the weekday of a date as a string: 'Monday', 'Tuesday', ..., 'Sunday'. If the date does not exist, such as 30 February, return 'Invalid date'.
Work it out from the calendar rules yourself, without the datetime or calendar modules:
day_of_week(2026, 10, 20) # returns 'Tuesday' day_of_week(2000, 2, 29) # returns 'Tuesday' day_of_week(1900, 2, 29) # returns 'Invalid date' day_of_week(1, 1, 1) # returns 'Monday'
month and day are whole numbers but may be out of range, like month 13 or day 0Ready?
Accept the challenge to start writing. A small timer counts the time this page is in view.
Output appears here.