Nested Loops
Coding & Systems · repetition · use a loop inside a loop

Kavi Fills the Window Boxes
Kavi had 3 window boxes to decorate, and wanted 4 flowers in each one. "I am NOT writing plant a flower twelve times!" hooted Kavi. So Kavi wrote a loop inside a loop: Repeat 3 times: [ Repeat 4 times: plant a flower ]. The outer loop counts the boxes; the inner loop fills each one. The inner loop runs all 4 flowers, then the outer loop moves to the next box and the inner loop runs again. "A loop inside a loop is a nested loop," said Kavi. "3 boxes, 4 flowers each — that is 3 × 4 = 12 flowers, from just two short lines!"
What your child will learn
A peek inside
Try this at home: A loop placed inside another loop is called a ____ loop.
Ready to play and learn?
Start the free interactive lesson, or print the handout for screen-free play.
Part of Computing · Stage 5 · S5 on KAVI Academy — a secular, whole-child learning platform for ages 5–12.
