Tracing selection with a trace table
Check the condition using the current values, record TRUE or FALSE in the trace table, then follow only the branch that is true and skip the other branch.
Understanding Tracing selection with a trace table in Years 7–8 Creating Digital Solutions
What it does: The middle column records TRUE or FALSE for the condition, which shows which branch to follow. 4 > 10 is FALSE, so x <- 0 is skipped and x stays 4 in the trace table. 7 is not greater than 10, so the condition is FALSE. The line inside the if-then block is skipped. 50 >= 50 is TRUE because the >= operator includes equal values. So "Pass" is printed. Recording the condition result does not change any variables. It helps you see and check which path the algorithm took. Always use the current values of variables at that moment in the trace, not old ones.
Common mistakes: The condition uses the assignment arrow ←, which stores a value. A condition has to compare, so it should be: if score ≥ 50 then. Without a comparison there is no TRUE or FALSE to record in the trace table. The assignment is backwards. The variable name goes on the left of the arrow and the value on the right: temp ← 31. Without this, the trace table has no starting value for temp.
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 3–47) 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
trace an ifFill in the Blanks
Spot the Error
Student with a class code? Join your class →