CoursePython from Scratch to Intermediate · Module 9: Classes and Objects · part 60 of 75
Part 60 · Module 9: Classes and Objects

Lesson 1: Classes, your own kinds of object

17 min read·14 Oct 2026
Module 9 · Lesson 1 · About 50 minutes · Needs: Module 6 (functions, parameters), Module 7 (imports, the booknook package, date), Module 3 f-strings

The situation

Amira wants lending and returning done properly. "When Jonah's Frankenstein is out, I want the program to know it is out, know it is his, and know what he owes, without you looking anything up."

Right now a loan is a dictionary, and its rules are loose functions in booknook/dates.py and booknook/fees.py. This lesson builds your own kinds of value, Book, Member and Loan, that carry their data and rules together. Jonah's loan L04, Frankenstein, borrowed Monday 14 September 2026, 16 days late today and capped at 300 pence, runs through the lesson.

NOW: YOU CARRY THE LOAN loan dict L04, 14 Sep days_late 16 late_fee 300p THIS LESSON: ASK THE LOAN l04.fee(TODAY) data and rules in one object 300p 16 days late
Today you carry Jonah's loan from function to function by hand; by the end of the lesson the loan itself (blue, your code) answers l04.fee(TODAY) with 300p (green, the right answer).

The rest of this part opens with an account

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