← Back to course
Code Crew G3 / Week 02 / Monday
1/6
Week 02 Β· Loops

Monday

// Doing it again

Monday: Meet the Idea

Raven is making a bead bracelet. "Red, blue, red, blue," she says. Soon she is tired of saying it.

Rocket jumps up. "I have an idea!" he says. "Just say red and blue twenty times."

"That is a loop," Nova says. "A loop repeats a step." Raven smiles. "What do you notice about the pattern?" she asks.

Let's write the bracelet pattern. Then we'll try a clapping loop.

RAVEN was making a beaded bracelet: red, blue, red, blue, red, blue, red, blue. After saying it twenty times Raven got tired. ROCKET said: 'Just say RED-BLUE 20 times.' That is a LOOP.

Big Idea
A LOOP repeats a step.
It can repeat a fixed number of times (REPEAT 5 TIMES) or
until something happens (REPEAT UNTIL the floor is clean).

Quick Try

Write the bracelet pattern below. Repeat RED-BLUE four times.

Pattern:

Now write what REPEAT 6 TIMES of CLAP-CLAP-STOMP looks like.

Pattern:

Loops Save Writing

Rocket wrote clap five times, on five lines. Raven wrote one loop instead.

Both programs make five claps. The loop is shorter to write and easier to change.

LONG WAY
  clap
  clap
  clap
  clap
  clap

LOOP WAY
  REPEAT 5 TIMES:
      clap
COUNT THE LOOP
  • Read the question.
  • Tap your answer.
REPEAT 4 TIMES: jump. How many jumps?
REPEAT 3 TIMES: (hop, hop). How many hops?
Which way is shorter to write?
REPEAT UNTIL the cup is full: pour. When does it stop?
REPEAT 5 TIMES: (red, blue). How many red beads?
Same loop. How many beads in all?
REPEAT 2 TIMES: (snap, snap, clap). How many snaps?
StatementTrue or false?
A loop repeats steps.?
REPEAT 3 TIMES runs its steps 3 times.?
A REPEAT UNTIL loop always runs 10 times.?
Loops make programs longer to write.?
WHY THIS EXERCISEA loop is a short way to say do this again.
Rocket claps 3 times, then 3 more, then 3 more. One loop does it all: REPEAT ___ TIMES: clap. What number?
WHY THIS EXERCISEWhen a step repeats, a loop with the right number says it in one line.
Try it
Clap this loop: REPEAT 4 TIMES: clap, clap, stomp.
Count the stomps out loud as you go.
Make up a new loop for a grown-up to clap.

Quick Check

The loop is REPEAT (clap, clap, stomp) 2 TIMES. How many stomps? ____
Same loop. How many claps? ____