Code Crew G2 / Week 04 / Wednesday
3/6
Week 04 Β· Loop Logbooks

Wednesday

Repeat steps times
// Track a box through every lap
⏱ about 15 min
Rocket the inventor holding his engineering tablet

A box can count laps!

Nova finds a new kind of repeat line.

It does not say 3 times or 4 times.

It says repeat steps times.

Rocket scratches his head.

How many laps is that?

Raven smiles. Look inside the steps box!

WARM-UP: SAY IT EVERY LAP
  • Nova speaks every lap.
  • Tap the last number.
set steps to 0
repeat 3 times:
change steps by 1
say steps
?
set height to 4
repeat 2 times:
lower height by 1
say height
?
A loop that says repeat steps times

Repeat steps times

Nova peeks in the steps box.

The box holds 3.

So the loop runs 3 laps.

set steps to 3
repeat steps times:
flash lights
stop
land
A memory box named steps holding the number 5

Change the box, change the laps

Set steps to 5 instead.

Now the loop runs 5 laps.

One number changes the whole loop!

HOW MANY LAPS?
  • Peek in the box.
  • Tap the answer.
set steps to 4
repeat steps times:
flash lights
?
set steps to 2
change steps by 1
repeat steps times:
clap wings
?
set steps to 5
set count to 0
repeat steps times:
change count by 1
stop
say count
?

Build a flight with 3 flashes.

Steps starts at 2.

Add one before the loop.

BUILD A FLIGHT WITH 3 FLASHES
  • Fill the box, add one, then loop.
1line 1
2line 2
3line 3
4line 4
Raven the explorer with her wrist computer

What do you notice?

Fill the box before the repeat.

An empty box means zero laps.

set steps to 2
set height to 1
repeat steps times:
change height by 2
stop
say height
afterheighttrue?
line 21?
lap 13?
lap 24?
Nova says5?
TRICKY ONES!
  • Read every line carefully.
  • Tap what Nova says.
set count to 0
repeat steps times:
change count by 1
stop
say count
?
set steps to 2
set count to 5
repeat steps times:
lower count by 2
stop
say count
?

The box counted the laps!

Repeat steps times peeks in the box.

The box sets the number of laps.

Fill the box first!

Great work, Crew!

← Tuesday