CoursePython from Scratch to Intermediate · Module 6: Functions · part 40 of 75
Part 40 · Module 6: Functions

Lesson 1: Defining functions, giving a piece of work a name

15 min read·14 Oct 2026
Module 6 · Lesson 1 · About 45 minutes · Needs: Modules 1 to 5 (variables, f-strings, if, loops, lists)

The situation

Amira has a complaint. "Last week you told me Ben owed 180 pence. Yesterday your notebook said something else. I want the same answer every time." She is right to worry. Your fee sum is typed out afresh in every cell that needs it, and every copy is a chance to type it differently.

This lesson gives each rule one name and one home. Ben's loan L13, The War of the Worlds, borrowed on shelf day 21, runs through the whole lesson: due on day 35, 9 days late on day 44, 180 pence owed.

BEN, LOAN L13, THE WAR OF THE WORLDS 21 borrow day 35 due day 9 days late 180p late fee due_date days_late late_fee reminder_text Dear Ben, ... Fee so far: £1.80.
Ben's loan runs through four named functions: borrow day 21 becomes due day 35, then 9 days late, then 180p, then a reminder (blue is your code, green the finished answer).

The rest of this part opens with an account

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