Code Crew G2 / Week 04 / Tuesday
2/6
Week 04 Β· Loop Logbooks

Tuesday

Say it every lap
// Track a box through every lap
⏱ about 15 min
Rocket the inventor holding his engineering tablet

Say it every lap!

Rocket wants to hear the auto-pilot count.

He puts a say line inside the loop.

Now Nova will speak on every lap.

Raven gets her notebook ready.

She wants to write down every number.

WARM-UP: LAP BY LAP
  • Follow the loop.
  • Tap what steps holds.
set steps to 0
repeat 2 times:
change steps by 1
?
set steps to 3
repeat 2 times:
change steps by 1
stop
land
?
A loop with say steps inside it, under the repeat

Nova speaks every lap

The say line is inside the loop.

So Nova speaks on every lap.

Nova says 1, then 2, then 3.

set steps to 0
repeat 3 times:
change steps by 1
say steps
A lap logbook with a steps column and a height column

Two boxes, one loop

A logbook can track two boxes.

Each box gets its own column.

Both boxes grow by 1 each lap.

WHAT DOES NOVA SAY LAST?
  • Nova speaks every lap.
  • Tap the last number Nova says.
set steps to 0
repeat 4 times:
change steps by 1
say steps
?
set height to 1
repeat 3 times:
change height by 1
say height
?
set steps to 0
repeat 2 times:
say steps
change steps by 1
?

Build a counting flight.

Nova must say 1, then 2.

Steps starts at 0.

BUILD A COUNTING FLIGHT
  • Make Nova say 1, then 2.
  • Lines under repeat run every lap.
1line 1
2line 2
3line 3
4line 4
Raven the explorer with her wrist computer

What do you notice?

Read one column at a time.

One box can go up.

The other box can go down!

set steps to 0
set height to 5
repeat 3 times:
change steps by 1
lower height by 1
afterstepsheighttrue?
lap 114?
lap 224?
lap 332?
TRICKY ONES!
  • Read every line carefully.
  • Check the name tags.
set steps to 0
set height to 5
repeat 2 times:
change steps by 1
lower height by 1
?
set height to 2
set steps to 0
repeat 3 times:
change steps by 1
stop
say height
?

Nova counted every lap!

A say line in the loop speaks every lap.

Each box gets its own column.

See you tomorrow, Crew!

← Monday