Computational thinking · debugging

Debug the
Boundary Counter.

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

Learning rule: Trace each input. A matching final total is not enough evidence.

Illustration of pupils collaborating in a classroom.
One short prompt, a visible trace, and a reasoned repair.

Interactive demonstration

Follow the evidence

01 · 02 · 03

01 Predict before you trace
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 the faulty final count

Teacher notes

A focused 5–8 minute discussion

Use this as a warm-up, a small-group intervention, or a projector conversation before pupils write an explanation.

  1. Point: Ask pupils to point to the one symbol that makes 5 count.
  2. Speak: Invite: “Why does a final count of 1 fail to prove the repair?”
  3. Keyboard: Tab to choices; Enter or Space selects them. Arrow keys reveal the trace in the focused table.
  4. Extend: Ask which test reveals an accidental >= 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

Build on this debugging lesson.

Browse related classroom resources available directly from Milestone Teachers.

This free mini-experience remains available without an account or purchase.

Browse classroom resources