Lesson 1: Modules and imports: the shelf rules in one file
16 min read·14 Oct 2026
Module 7 · Lesson 1 · About 45 minutes · Needs: Modules 1 to 6 (functions withdefandreturn, docstrings,assert,%%writefileand!pythonfrom Module 1 Lesson 2)
The situation
Amira's next request is "Use real dates." First the shelf's code needs a home. late_fee lives in a notebook cell, and every new notebook types it out again, until one copy says 20 pence a day and another says 25.
This lesson moves the rules into one file, fees.py, that every notebook can borrow from. You will follow Ben's L13, 9 days late, which should cost 180 pence wherever it is asked. By the end the file sits in a folder called booknook: the start of the shelf's package.