Curriculum

Curriculum

Repeat Until the Task Is Done

Scenario

A library volunteer labels three books. Each pass labels one unlabelled book.

  1. 1Three books left
  2. 2Two books left
  3. 3One book left
  4. 4Zero books left

Try it yourself

Predict how many passes occur before the loop stops.

Reveal the explanation
  1. Three books left

    Label one. Two remain.

  2. Two books left

    Label one. One remains.

  3. One book left

    Label one. Zero remain.

  4. Zero books left

    Stop. The loop body runs three times.

Try starting with zero books. If the condition is checked first, the loop body runs zero times.

Your turn

Trace the loop for zero books and for two books, including the final check.

Common mistake Repeating an action without changing the condition.

Check your work

Two traces show zero and two iterations. Both end with zero books left.