count = 0
for each value in [4, 5, 6]:
if value >= 5:
count = count + 1
What result will the faulty code give?
Start at 0. Choose a prediction before you reveal the trace.
Choose a count, then reveal the trace.
A 3–5 minute classroom code lab
Computational thinking · debugging
A counter should count values greater than 5. Can you find the smallest safe repair and prove it with a fresh boundary check?
No login No pupil data Ready to teach
Interactive demonstration
01 · 02 · 03
count = 0
for each value in [4, 5, 6]:
if value >= 5:
count = count + 1
Start at 0. Choose a prediction before you reveal the trace.
Choose a count, then reveal the trace.
Use Left / Right or the buttons to reveal one row at a time. On a small screen, focus the table and use Home / End to see every column.
| Input | Test | Decision | Count after |
|---|
0 of 3 inputs revealed
5 >= 5 is true, so the code counts 5 even though “greater than 5” must exclude it.Each choice ends with a total of 1. Look at which input it counts.
| Rule | Input 4 | Input 5 | Input 6 | Total |
|---|
Only the intended rule counts the input above 5.
Select a repair to compare all three input decisions.
total > 50A discount applies only when the total is greater than 50. Choose an outcome for every total before checking.
Teacher notes
Use this as a warm-up, a small-group intervention, or a projector conversation before pupils write an explanation.
>= when a rule says “greater than.”Source basis: A-C5-3 in Assessments p. 10 and Answer & Reasoning Key p. 12; C-C5-3 in Assessments and Key p. 30; boundary testing and safe repair in Student Intervention Lab pp. 41–44 (P5-L2/P5-L3). This public illustration is new; it is not the included interface.
Continue the practice
Browse related classroom resources available directly from Milestone Teachers.
This free mini-experience remains available without an account or purchase.