🤖 Garden robot
Why does a loop inside a loop multiply?
A little robot plants flowers by following code. Watch it run blocks one after another, team up with a second robot, and repeat. Then guess how many flowers a loop inside a loop plants.
Run the robot ↓Four ways code can run.
Press Next step. Watch the glowing block and the garden.
🤖 Garden robotStep 1 of 6
“There’s a 3 and a 4. 3 + 4 = 7 flowers!”
The inner loop runs all 4 times on every lap of the outer loop.
4 + 4 + 4 = 3 × 4 = 12.
4 + 4 + 4 = 3 × 4 = 12.
🌸 0 flowers⏱ 0 ticks
Outer
Inner
Your turn: 5 robot challenges
Read the code, change the code, predict what the robot does.
🎯 Challenge0 of 5 done
⭐ You saw through the trap
A loop inside a loop multiplies.
Sequenceone block after another, top to bottom
Togethertwo robots at once: done when the longer one is
Repeatthe same blocks again, lap after lap
Nested3 laps of 4 = 3 × 4 = 12
Code runs in four shapes. Sequential code runs one block after another. Concurrent code runs at the same time, like two robots starting together. A repeat loop runs the same blocks over and over. A nested loop puts a loop inside a loop, and the inner loop runs all the way through on every lap of the outer one, so the counts multiply. Change one number in the code and you can predict exactly how the garden changes.