Choosing test data for an algorithm
Chosen inputs, each with the output you expect, picked so every path (branch) through an algorithm gets tested. Compare the real result to the expected output.
Understanding Choosing test data for an algorithm in Years 7–8 Creating Digital Solutions
What it does: The expected output is decided first. After running, you compare the real result with "Fail" to see if the algorithm works. A score of 80 tests the then branch and 20 tests the else branch, so both paths are covered. Use one test per branch so every path through the algorithm gets run at least once. Age 15 is in the 13-19 range, so "Teen" is the output you expect. Age 8 would take the other branch and should give "Not a teen".
Common mistakes: The rule does not match the tests. A mark of 50 or more should be a Pass, so the rule should say 'is a Pass'. Test data only works if the expected outputs follow the rule. An input of 15 is in the 13-17 range, so the expected output is Teen, not Adult. Each test needs the correct expected output for its branch.
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 50–125) and word search (Modules 3–125).
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
test dataFill in the Blanks
Spot the Error
Student with a class code? Join your class →