Primary Wiki · Computing · KS2

What is a loop in coding?

A loop is an instruction that tells a program to repeat something, instead of writing the same instruction over and over again.

Why loops are useful

To draw a square, you could write "move forward, turn" four times. A loop lets you write it once and say "repeat 4 times", which is shorter and easier to fix.

Types of loop

  • A count loop repeats a set number of times: "repeat 10 times".
  • A forever loop keeps going until the program is stopped.
  • A condition loop repeats until something happens: "repeat until you reach the wall".

Where this sits in the curriculum

Repetition and loops are a key part of KS2 programming, especially in Scratch.

All Wiki articles