World 2: Loops
Long roads
- The roads are longer now. Ten
rightlines? Too many! - A loop repeats lines for you.
Words for this world
| Word | Meaning |
|---|---|
| loop | code that runs again and again |
| repeat | do the same thing one more time |
| pattern | moves that come again in the same order |
Repeat a move
- Everything inside the loop repeats.
- Find the pattern on the map, then put it inside the loop.
DECLARE i : INTEGER
FOR i ← 1 TO 3
OUTPUT "right"
NEXT i
OUTPUT "down"
Dificultad 2/5 · 140 monedas + un pequeño bono en el primer intento de hoy
Home is 10 squares to the right. Do not write 10 lines: use a loop.
Haz clic en Ejecutar para ver la salida aquí.
Dificultad 2/5 · 140 monedas + un pequeño bono en el primer intento de hoy
Walk down the stairs: right, down, right, down… Repeat the two moves with a loop.
Haz clic en Ejecutar para ver la salida aquí.
Dificultad 2/5 · 140 monedas + un pequeño bono en el primer intento de hoy
Every second square has a star. Use a loop that moves right two times on each turn.
Haz clic en Ejecutar para ver la salida aquí.
Dificultad 3/5 · 200 monedas + un pequeño bono en el primer intento de hoy
Find the pattern: right, right, down. Repeat it with a loop.
Haz clic en Ejecutar para ver la salida aquí.
Dificultad 3/5 · 200 monedas + un pequeño bono en el primer intento de hoy
Go right to the end, down two squares, then left all the way home. Use a loop for each long walk.
Haz clic en Ejecutar para ver la salida aquí.
Dificultad 3/5 · 200 monedas + un pequeño bono en el primer intento de hoy
Walk around the garden and collect all 4 stars. Home is just below the start, so you finish there.
Haz clic en Ejecutar para ver la salida aquí.