Coding Education for Young Minds: Engage, Educate, Empower

Free Coding Lesson Plan: Loops for Grades 2–4

Use a repeating pattern to introduce loops before children type any code. This free lesson is designed for Grades 2–4; adjust the number of steps to suit pupils’ experience. Children can speak, point to picture cards or move their hands while staying seated.

Time: 30 minutes. Materials: paper, pencils and a board. No computer or account is needed. Learning goal: identify a repeated sequence, express it as a loop and predict how many actions it produces.

Key vocabulary

A sequence puts instructions in order. A loop repeats a set of instructions. In this activity, the repeat count tells us how many times to carry out the whole set, rather than how many individual actions to perform.

1. Spot the repeating part — 5 minutes

Draw this pattern on the board: circle, square, circle, square, circle, square. Ask pupils to identify the smallest group that repeats. Underline each circle-square pair. There are three pairs and six shapes altogether.

Now write: REPEAT 3 TIMES: draw a circle; draw a square. Explain that this shorter instruction produces the same pattern as writing all six drawing instructions.

2. Run a classroom loop — 5 minutes

Write: REPEAT 3 TIMES: tap the desk once; raise one hand. Demonstrate one complete round. Then count the three rounds aloud while children perform, describe or point to both actions in each round. Ask: how many taps? How many hand raises?

Answer: three taps and three hand raises. Six individual actions occur, but the loop runs three times. Keep returning to the boundary of the repeated group if children confuse these counts.

3. Programme a partner — 10 minutes

In pairs, one pupil chooses a two-shape pattern and writes a repeat count from two to four. The other pupil draws the result, following the instruction exactly. Swap roles. Ask each pair to compare the compact instruction with the expanded drawing.

Have children predict the total number of shapes before drawing. A loop with two shapes repeated four times produces eight shapes. Let pupils count groups if multiplication is not yet familiar.

4. Debug the repeat count — 5 minutes

Show a target pattern containing four circle-square pairs. Beside it, write REPEAT 3 TIMES: draw a circle; draw a square. Ask pupils to test the instruction, compare the result with the target and change only what is necessary.

Teacher answer: change the repeat count from three to four. The instructions inside the loop stay the same. Discuss why adding unrelated instructions would make the solution harder to follow.

5. Exit question — 5 minutes

Ask pupils to expand REPEAT 2 TIMES: draw a triangle; draw a circle; draw a square. Then ask how many shapes the loop makes.

Answer: triangle, circle, square, triangle, circle, square: six shapes. Two rounds each contain three drawing actions.

Support, challenge and next steps

Support: use two repeats and picture cards. Challenge: ask whether two different loop instructions can produce eight shapes, then have children explain their answers. For example, a two-shape group repeated four times and a four-shape group repeated twice both make eight shapes, although their patterns may differ.

When pupils later use a visual coding tool, connect its repeat block to the paper loop. Start with the same two instructions so the new interface does not obscure the familiar idea.

Explore more free coding lesson plans, see our Grade 1–6 curriculum, or request resources for your school.