#575 · Modules and random · Beginner · 35 XP · about 6 min
A school library lends books for a number of days. Write due_date(borrowed, days) where borrowed is the date a book was taken out, written 'YYYY-MM-DD', and days is the length of the loan:
days days to the date.'Monday 2026-11-16'.The datetime module does the calendar work: date.fromisoformat reads the date, adding a timedelta(days=...) moves it on, weekday() gives 0 for Monday up to 6 for Sunday, and strftime('%A') gives the weekday's name.
due_date('2026-11-02', 14) # returns 'Monday 2026-11-16' due_date('2026-11-02', 13) # returns 'Monday 2026-11-16' due_date('2026-11-07', 7) # returns 'Saturday 2026-11-14'
With 13 days the book would be due on Sunday 15 November, so it moves to the Monday.
1 <= days <= 1000First solves only, ranked by stars and then time.