Save resource to class

Loading your classrooms…

Sign in to save

Bookmark this page so you can find it later.

LivePhysics staff accounts use their usual sign-in provider below.

Sign in to save

Bookmark this page so you can find it later.

LivePhysics staff accounts use their usual sign-in provider below.

Report an Error

Reported page · Tool

Loops & Pattern Coder

/tools/loops-pattern-kids/

This helps us reproduce what you saw. Clear the link to leave it out.

or drop them here

Up to 3 images or PDFs, 5 MB per file. 0 of 3 attached.

Loops & Pattern Coder

A loop runs the same steps again and again. Pick your actions, set the repeat count, and watch your pattern build automatically.

How Loops Save Work

Both panels do the same thing. A loop is a shortcut for repeating steps.

Without a loop

Stamp Blue
Stamp Blue
Stamp Blue
Stamp Blue
Stamp Blue
Stamp Blue

With a loop

Repeat 6 times
Stamp Blue

3 lines instead of 6!

Output so far

A loop that repeats N times with M actions inside produces N x M output tiles.

How Loops Work

What Is a Loop?

A loop tells a computer to repeat a set of steps a certain number of times. Instead of writing the same instruction six times, you write it once and say "repeat 6 times."

Real programs use loops for everything, drawing shapes, playing music beats, showing a countdown, and filling a grid with tiles.

Loop Count

The number at the top of the loop block is the repeat count. It controls how many times the loop runs.

  • Repeat 1 time, runs the body once (same as no loop)
  • Repeat 4 times, runs the body 4 times in a row
  • Repeat 0 times, never runs - produces nothing

Loop Body

The loop body is the set of steps inside the loop. Every time the loop runs, all the steps in the body happen in order.

If the body has 2 actions and the count is 3, the total output is 2 x 3 = 6 tiles. You can predict the length before you run it.

Nested Loops

A nested loop is a loop inside another loop. The outer loop runs the inner loop multiple times. This is how programs fill grids.

  • Outer loop = number of rows
  • Inner loop = number of columns in each row
  • Total tiles = outer count x inner count

Related Content