← Back to course
Code Crew G3 / Week 02 / Thursday
4/6
Week 02 Β· Loops

Thursday

// Doing it again

Thursday: Jump-Rope Counting

Rocket and Raven grab jump ropes. Rocket can jump six times. Raven can jump nine times.

"Let's each do four rounds!" Rocket says. Raven smiles. "What do you notice about rounds?" she asks. "Each round is a loop."

Nova blinks. "One loop today might never stop," she says. "Watch for it."

Let's count the jumps. Then we'll hunt for the forever loop.

Rocket can jump 6 times before tripping. Raven can jump 9 times. If they each do REPEAT 4 TIMES of their best round, count the jumps.

Rocket's total jumps: 4 Γ— 6 = ____
Raven's total jumps: 4 Γ— 9 = ____
All jumps together: ____

Find the Loop in the Wild

Each sentence is doing a loop. Write what is repeating.

I brushed each tooth, top and bottom. Repeating: ___________
I put one shoe on, then the other. Repeating: ___________
We sang the chorus three times. Repeating: ___________

Spot the Bad Loop

One of these loops will run FOREVER and never stop. Circle which one.

(A)  REPEAT 10 TIMES:
         clap

(B)  REPEAT UNTIL it is sunny:
         smile
     (it has been sunny all morning)

(C)  REPEAT UNTIL pigs can fly:
         wait
The forever loop is:
WHY THIS EXERCISEInfinite loops are a common bug. Always make sure your stopping condition can actually become true.

Loops Times Laps

A loop can hold more than one step. To count, look at one lap first.

Then count the steps in one lap, and add them up for every lap.

REPEAT 4 TIMES:
    hop
    hop
    spin
How many hops in all?
How many spins in all?
How many moves in all, hops and spins together?
WILL IT STOP?
  • Read the question.
  • Tap your answer.
REPEAT 5 TIMES: (jump, jump). How many jumps?
REPEAT UNTIL the sun turns green: wait. Will it stop?
REPEAT UNTIL the timer rings: stretch. Will it stop?
Rocket does REPEAT 3 TIMES of 7 jumps. How many jumps?
StatementTrue or false?
A loop that never stops is a forever loop.?
A REPEAT UNTIL loop needs a stop that can really happen.?
REPEAT 2 TIMES: (clap, clap) makes 4 claps.?
REPEAT 6 TIMES: wave makes 7 waves.?
WHY THIS EXERCISEGood programmers make sure every loop has a way to stop.
Try it
Do this loop: REPEAT 3 TIMES: touch your toes, reach up high.
Count your reaches out loud.
Did you reach up 3 times?
Try Without Paper
Make up a REPEAT UNTIL loop with someone in the car.
Example: 'REPEAT UNTIL we see a red car: I count houses.'
← Wednesday