Browse topics

Curriculum

Explore all 1,858 open curriculum concepts.

Advanced filters 2

Computing Algorithms & Programming Ages 9–13

Nested loops in code

Write, run, read and alter code (block-based or text-based) that places one loop inside another (for example a loop that draws a square, repeated with a turn after each square to make a rotating pattern), predict how many times the inner steps run altogether (outer repeats × inner repeats), and describe how changing the inner or the outer loop changes the outcome

Teach
Share

Activity

A nested loop runs an inner repeat for each outer repeat.

Materials

  • Outer loop card
  • Inner loop card
  • Action tile (stamp or clap)
  • Paper grid 3×3
  • Pencil

Steps

  1. Adult demos outer×2 with inner×3 stamps and counts total stamps (6).
  2. Child runs outer×3 / inner×2 on the grid and records the total.
  3. Child predicts total for outer×2 / inner×4 before running.
  4. Fresh check: give new outer/inner numbers; child states total without running. Record and stop.

Done

Ask how to find the total. Success: multiply or count systematically.

Example. “Outer 2 × inner 3 = 6 stamps.”

4 before 0 after

Loading map…
List nearby topics

This concept

Nested loops in codeProcedural concept

Next

No next concept

Ways to teach

Pick a way to teach this topic. Come back here afterward to record progress.

Code.org

Hour of Code

Open (new tab)
About this link

Hour of Code supports Nested loops in code. An adult previews and guides; this is a learning page, not a scored quiz.

Code.org. “Hour of Code.” External page; Gakuva does not copy, host, embed, or redistribute materials.

Unknown — link only

Check understanding and curriculum record

Family records and proof options

Keep a record of your learning

Save photos, notes, and attendance. Export a proof packet for compliance or portfolio reviews.

Check understanding

“When your child codes — with blocks in an app like Scratch or with typed code — can they put one 'repeat' loop inside another, for example to draw a ring of squares, and say how many times the inside part will run before they run it?”
Full curriculum checks
  • Write and run code with a loop inside a loop (e.g. repeat a 'draw a square' loop 6 times with a turn after each square) and check that the result matches the plan
  • Read a program with nested loops and predict how many times the inner action happens altogether (e.g. repeat 3 [repeat 4 [clap]] claps 12 times), then run it to check
  • Change either the inner or the outer repeat count in nested-loop code, then explain and test how the change affects what happens
Curriculum record
Type
Procedural
Subject
Computing
Domain
Algorithms & Programming
Age range
Ages 9–13

Standards

the-ontario-curriculum-mathematics-2020:ON-MATH-2020-G4-C3.1the-ontario-curriculum-mathematics-2020:ON-MATH-2020-G4-C3.2the-ontario-curriculum-mathematics-2020:ON-MATH-2020-G5-C3.1the-ontario-curriculum-mathematics-2020:ON-MATH-2020-G5-C3.2the-ontario-curriculum-mathematics-2020:ON-MATH-2020-G6-C3.1the-ontario-curriculum-mathematics-2020:ON-MATH-2020-G6-C3.2the-ontario-curriculum-mathematics-2020:ON-MATH-2020-G7-C3.1the-ontario-curriculum-mathematics-2020:ON-MATH-2020-G7-C3.2