Working out the expected output before you run the code
The correct result of a test case, worked out by hand from the specification before running the code. Never copy it from the program's own output, or the test proves nothing.
Understanding Working out the expected output before you run the code in ACARA Digital Technologies Years 9–10
What it does: The expected output comes from the spec's rule, calculated by hand as 3 x 4 = 12, before running the program. If you decide the expected output after seeing the result, you can be tricked into accepting a wrong answer. The spec says what the program SHOULD do. The program only shows what it DOES do, and that may contain bugs. The correct average is (10 + 20) / 2 = 15. Copying 18 makes the test pass, but the bug is still there. A hand calculation is independent of the code. Copying the output only repeats whatever the code does, even when it is wrong.
Common mistakes: The expected value was calculated with the program's own formula, so the test can never fail. Work it out by hand from the spec: 4 * 3 = 12, so it should be expected = 12. The expected output must be worked out by hand (10% of 20 is 2.0 or 20 * 0.10), not taken from the function being tested. Using discount(20) just compares the function with itself.
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 536–590) 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
expected outputFill in the Blanks
Spot the Error
Student with a class code? Join your class →