NameError: using a name Python does not know
An error Python raises when code uses a variable or function name it does not know, often from a typo, wrong capitals, missing quotes or using a name before it is assigned.
Understanding NameError: using a name Python does not know in ACARA Digital Technologies Years 7–8
What it does: The variable was made as name in lowercase, so asking for Name with a capital N causes a NameError. Assigning total on the first line means Python knows the name when print() uses it on the next line, so there is no NameError. Python is case-sensitive. age and Age are different names, so using the wrong capitals can cause a NameError. Text needs quotes. Without them Python looks for a variable called Hello and cannot find it.
Common mistakes: Ava is text, so it needs quotes. Without them Python looks for a variable called Ava and raises a NameError. It should be name = "Ava". scor is a misspelling of score. Python does not know a name called scor, so it raises a NameError. It should be score = score + 5.
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 482–519) and word search (Modules 420–519).
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
NameErrorFill in the Blanks
Spot the Error
Student with a class code? Join your class →