Skip to content
KinPilot™Learn & Explore
Menu

Grades K–2 · Computing

How does a loop repeat a step and then stop?

A loop tells a character to do the same step again. The step sits inside the loop. Here the inside step is Right: move one square toward the right side of the page.

D11 visual explanationThe finite loop repeats the single page-right move 3 times. The expanded instructions are Right, Right, Right. Starting in square zero, the character makes 3 one-square moves and ends at square 3.A finite loop repeats its inside stepRepeat 3 timesRight →0123453 rightward moves; finish at 3.The loop stops after its stated number of repeats.

In the diagramA finite loop repeats its inside stepRepeat 3 timesRight →0123453 rightward moves; finish at 3.The loop stops after its stated number of repeats.

Repeating Right three times moves the character from square zero to square three.

The loop says repeat three times. That means Right, then Right, then Right. Each move counts once. Starting at square zero, the character reaches square three after those three moves.

The loop then stops. Its repeat count has been used up. Writing one step with a count can describe repeated moves without writing a separate copy of every step.

About this explanation

Starting knowledge: Count up to four and follow a one-square page-right instruction.

Sources

  • University of Canterbury, CS Unplugged — Kidbots: repetition and loops
← Grades K–2 topics