CoursePython from Scratch to Intermediate · Module 7: Modules, the Standard Library and Packages · part 47 of 75
Part 47 · Module 7: Modules, the Standard Library and Packages

Lesson 2: Numbers, chance and real dates from the standard library

16 min read·14 Oct 2026
Module 7 · Lesson 2 · About 50 minutes · Needs: Module 7 Lesson 1 (import and from ... import), Module 6 (functions, return, assert), Module 5 (lists and dictionaries)

The situation

Amira has stopped counting shelf days. "Use real dates," she says. "Jonah does not know what day 44 is. He knows it is Wednesday."

Until now you counted shelf days by hand. This lesson hands the counting to Python. You will follow Jonah's loan L04, Frankenstein, borrowed on Monday 14 September 2026, to a real "16 days late" on Wednesday 14 October 2026, picking up rounding and repeatable random choices on the way.

THE SAME DAY, TWO WAYS shelf day 44 a number you counted by hand this lesson date(2026, 10, 14) knows it is Wednesday and knows the calendar
Shelf day 44 (grey, the old way) becomes a real date (blue, your code's normal path) that knows its weekday, month lengths and leap years.

The rest of this part opens with an account

Signing up is free and takes one email. Nothing to pay, and nothing renews.