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

Crew Quest

// Doing it again

Crew Quest: Loop Hunt

Rocket hears the clock go tick, tick, tick. "That's a loop!" he says.

Raven looks around the room. "What do you notice that repeats?" she asks. "There's always another clue."

Nova scans the room. "Loops can hide in sounds and lights," she says.

Let's find three loops around us. Then we'll write one as code.

Find at least 3 loops happening AROUND you right now.

Examples: a clock ticking, your breathing, traffic lights, a fan spinning.

Loop 1: __________________________ Repeats every: __________
Loop 2: __________________________ Repeats every: __________
Loop 3: __________________________ Repeats every: __________

Pick one and write it as code

REPEAT _____ TIMES:
    ____________________________
Crew Brag Box
Show this page to a grown-up. Earn a CREW STAR β˜… for each loop spotted.

Week 2 Recap

  1. A LOOP repeats a step.
  2. REPEAT N TIMES: runs a fixed number of times.
  3. REPEAT UNTIL: runs until something becomes true.
  4. A loop that never stops is a 'forever loop', usually a bug.
Try This Without Paper
1. Count steps from your room to the kitchen; that's a loop, one step at a time.
2. Find a loop in a song you know (the chorus repeats!).
3. Make up a chore loop: REPEAT UNTIL the toys are away.
β—‡ LOOP LEADER
One person is the Loop Leader. They say a loop, like REPEAT 4 TIMES: hop.
Everyone else does the loop and counts out loud.
Then try a loop inside a loop: REPEAT 2 TIMES: (REPEAT 3 TIMES: clap).
Take turns being the Loop Leader.
Safety first
Hop in a clear space, away from furniture.
Rest if you get tired.
WEEK 2 REVIEW
  • Read the question.
  • Tap your answer.
What does a loop do?
REPEAT 2 TIMES: (REPEAT 3 TIMES: clap). How many claps?
Which loop could run forever?
REPEAT (clap, snap) 5 times. How many sounds?
StatementTrue or false?
REPEAT N TIMES runs a set number of times.?
REPEAT UNTIL stops when something happens.?
A loop inside a loop is called a nested loop.?
A forever loop is a good way to end a program.?
REPEAT 4 TIMES: (hop) makes 8 hops.?
WHY THIS EXERCISELoops save you from writing the same line again and again.

Coming up next…

Week 3: CONDITIONALS. IF this happens, THEN do that.

← Friday