Learn Without Walls
← Back to Module 5

Module 5: Study Guide

Review the key concepts from Loops and Repetition. Use this before the quiz or anytime you want a refresher!

Big Ideas

Repetition means doing the same thing more than once. When you brush each tooth, climb each stair, or eat each spoonful of cereal, you are repeating the same action.
A loop is a set of steps that repeat. Instead of writing the same steps over and over, you put them in a loop and say how many times to repeat them. Loops are one of the biggest ideas in coding.
The loop body is the part inside the loop that gets repeated. In "Repeat 4 times: clap, stomp," the loop body is "clap, stomp."
Loops save work. Writing 10 lines of the same instruction is slow, messy, and easy to mess up. Writing it once inside a loop is fast, clean, and error-free. That is why smart coders (the "lazy programmer") always look for loops.

Two Kinds of Loops

Count loop: Repeats a set number of times. You know exactly how many times it will run.
Example: "Repeat 5 times: jump." It jumps exactly 5 times and then stops.
Until loop: Keeps repeating until something changes. You do not know how many times it will run.
Example: "Repeat until the bowl is empty: take a bite." It depends on how much food is in the bowl.

How to Tell the Difference

Ask yourself: "Do I know exactly how many times this repeats?" If yes, it is a count loop. If no (it depends on something happening), it is an until loop.

Loops Are Everywhere

In daily life: Morning routines repeat every day. Eating cereal is a loop of scoop-lift-eat-lower. Setting the table for 4 people repeats the same steps 4 times.
In nature: Day and night, the seasons, your heartbeat, the water cycle -- all loops that repeat over and over.
In art: Patterns are loops you can see. Quilts, mosaics, tile work, and wallpaper all repeat the same design.
In music: Rhythms are loops you can hear. The chorus of a song repeats. A beat loops for the whole song.

Loops in Scratch

Repeat block: An orange block that runs the blocks inside it a set number of times. You type the number. When it finishes, Scratch moves on to the next block.
Forever block: An orange block that runs the blocks inside it over and over without stopping. It only stops when you click the red stop button. Use it for animations and games.
Drawing shapes: To draw a shape, use Repeat with "move steps" and "turn degrees" inside. The number of repeats = number of sides. The turn angle = 360 divided by the number of sides.

Shape Cheat Sheet

Triangle: Repeat 3, turn 120 | Square: Repeat 4, turn 90 | Pentagon: Repeat 5, turn 72 | Hexagon: Repeat 6, turn 60

The rule: turn angle x repeat number = 360

Review Questions

1. What is a loop?

A loop is a set of steps that repeat. You write the steps once and say how many times to do them.

2. Why are loops better than writing the same thing over and over?

Loops are shorter, cleaner, and less likely to have mistakes. If you need to change something, you only change it in one place.

3. What is the loop body in "Repeat 6 times: clap, snap"?

The loop body is "clap, snap." That is the part that repeats 6 times.

4. Is "keep looking until you find your keys" a count loop or an until loop?

It is an until loop. You do not know how many times you will look -- it depends on when you find your keys.

5. In Scratch, when would you use Forever instead of Repeat?

Use Forever when you want something to keep going the whole time your project runs, like a walking animation or a game that keeps checking for key presses. Use Repeat when you know exactly how many times.

6. To draw a triangle in Scratch, what do you put in the Repeat block?

Repeat 3 (because a triangle has 3 sides). Inside: move steps, turn right 120 degrees (because 360 divided by 3 = 120).
Take the Quiz Back to Module 5