Back to Grade 4

Coding: loops and conditions

Questions at easy, medium and hard levels. Pick a level and get a fresh set every time, with instant feedback.

Learn it A loop repeats steps. A "while" loop keeps going until its condition is false. Trace the value of each variable step by step.

Example: x = 3. While x < 50: x = x × 2. What is x at the end?

  1. 3 → 6 → 12 → 24 → 48 (still < 50, so loop again).
  2. 48 → 96. Now 96 is not < 50, so the loop stops.
  3. x = 96 (the loop ran 5 times).

Loading questions…