Math Bonk! Learning Centre Play the game

Coding with Loops

Marble run 1

What your child is learning

A program is a list of instructions that a computer follows exactly, in order, with no common sense. If you tell a robot "step, step, step, step", it takes four steps. If you tell it "repeat 4 times: step", it takes the same four steps with less writing. That second version is a loop, and loops are one of the first big ideas in coding.

In Grade 3, children work on code on paper and on screen. They should be able to:

Nested loops are a stretch, so there is no need to worry if they feel hard at first. This is the coding part of the Algebra strand. It continues coding with repeats and uses the same careful thinking as growing patterns.

A loop repeats a block of code: three moves forward, then one turn.A loop repeats a block of code: three moves forward, then one turn.Startrepeat 3 [ move forward 1 square ]Turn rightStop
A loop repeats a block of code: three moves forward, then one turn.

Why it matters

Coding teaches children to break a big job into small precise steps, and to find a pattern in those steps so the job becomes shorter. That is a strong thinking skill, whether or not they ever become programmers. It also gives meaning to multiplication: a loop that does 3 things 4 times is doing 3 × 4 things.

Debugging teaches something equally valuable: a mistake is not a failure, it is information. Programmers fix bugs all day long.

How to teach it

1. Be the robot

One person writes a program, the other follows it exactly, even when it is silly. Start simple: "step forward 3, turn right, step forward 3." Notice how exact words must be. "Turn" is not enough, a robot needs to know which way.

2. Find the repeat

Look at this program: forward 2, turn right, forward 2, turn right, forward 2, turn right, forward 2, turn right. Your child can spot that "forward 2, turn right" happens four times. Rewrite: repeat 4 times: forward 2, turn right. The path is a square with sides of 2 steps.

Worked example: What does this program do?
repeat 3 times: [ clap 2 times, stomp 1 time ]
Each pass of the loop gives 2 claps and 1 stomp.
Three passes: 3 × 2 = 6 claps and 3 stomps, 9 actions in total.

3. Count the actions

Ask how many total steps the robot will take. That connects the code to multiplication: 4 loops of 2 steps is 8 steps.

4. Stretch: put one loop inside another

repeat 2 times: [ repeat 3 times: [ clap ], stomp ]. The inner loop claps 3 times, and then there is a stomp, and all of that happens twice. Total: 6 claps and 2 stomps. Many children find nested loops tricky at first, so act them out with real claps.

5. Debug

Give your child a program with a mistake, such as a loop that runs 3 times when a square needs 4. Ask them to run it by hand, see where the path goes wrong and fix it. Show them that fixing is normal.

Common mistakes

Do this together

Loop rhythm band. Gather pots, wooden spoons and a cushion. Your child writes a rhythm as code on index cards, such as "repeat 3 times: [ bang pot, tap spoon ]" or the nested "repeat 2 times: [ repeat 3 times: [ clap ], stomp ]". The family plays it exactly as written. Before playing, everyone guesses how many sounds there will be in total, then counts to check. Swap roles and slip in a bug, such as a loop that runs 4 times when the tune needs 3. Who hears the mistake first?

Printable worksheet

17 questions, a picture warm-up and drawing tasks, with an answer key on its own page. Print it or save it as a PDF.

Open the worksheet

Every worksheet is on the printable worksheets page.

Ontario curriculum: Grade 3, Algebra, expectation C3 · official document · U.S. Common Core crosswalk