Recursion: a function calling itself
A function that calls itself with a smaller problem each time, and stops at a base case that returns without calling itself. With no base case, Python raises a RecursionError.
Understanding Recursion: a function calling itself in VCE Software Development U3O1
What it does: The if n == 0 line is the base case that returns without a further call, and countdown(n - 1) is the recursive case with a smaller number. A recursive function calls itself. The first one calls countdown(n - 1) inside its own body, but the second only prints. Each call must make the problem smaller. Starting from a positive n, adding 1 moves away from 0 and never stops.
Common mistakes: A single = assigns a value, so it cannot be used in a condition. The base case check must use == to compare: if n == 0:. A function header must end with a colon. It should be def factorial(n):.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 142–155) and word search (Modules 142–166).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
recursionFill in the Blanks
Spot the Error
Student with a class code? Join your class →