Looping through test cases and printing PASS or FAIL
Loops over each (input, expected) tuple in tests, unpacking it into two variables. Then you call the function, compare actual to expected, and print PASS, or FAIL with both values.
Understanding Looping through test cases and printing PASS or FAIL in ACARA Digital Technologies Years 9–10
What it does: The == operator checks whether the function's actual result equals the expected result, and PASS is printed only when they match. The for loop takes one tuple from tests each time and unpacks it into two variables: value and expected. Use == to compare two values. A single = assigns a value and causes a syntax error inside an if. FAIL belongs in the else branch, so it only runs when the comparison is False. The check is actual == expected, and 7 does not equal 10, so the test fails. Being bigger than the input doesn't matter.
Common mistakes: A single = assigns a value, so it cannot compare actual with expected. The test needs the comparison operator ==: if actual == expected:. An if statement must end with a colon. The line should be: if actual == expected:.
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 591–622) and word search (Modules 536–622).
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
for value, expected in tests:Fill in the Blanks
Spot the Error
Student with a class code? Join your class →