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.
for i in range(3):
print("right")
print("down")
רמת קושי 2/5 · 140 מטבעות + בונוס קטן בהשלמה הראשונה היום
Home is 10 squares to the right. Do not write 10 lines: use a loop.
לחץ על הרץ כדי לראות את התוצא כאן.
רמת קושי 2/5 · 140 מטבעות + בונוס קטן בהשלמה הראשונה היום
Walk down the stairs: right, down, right, down… Repeat the two moves with a loop.
לחץ על הרץ כדי לראות את התוצא כאן.
רמת קושי 2/5 · 140 מטבעות + בונוס קטן בהשלמה הראשונה היום
Every second square has a star. Use a loop that moves right two times on each turn.
לחץ על הרץ כדי לראות את התוצא כאן.
רמת קושי 3/5 · 200 מטבעות + בונוס קטן בהשלמה הראשונה היום
Find the pattern: right, right, down. Repeat it with a loop.
לחץ על הרץ כדי לראות את התוצא כאן.
רמת קושי 3/5 · 200 מטבעות + בונוס קטן בהשלמה הראשונה היום
Go right to the end, down two squares, then left all the way home. Use a loop for each long walk.
לחץ על הרץ כדי לראות את התוצא כאן.
רמת קושי 3/5 · 200 מטבעות + בונוס קטן בהשלמה הראשונה היום
Walk around the garden and collect all 4 stars. Home is just below the start, so you finish there.
לחץ על הרץ כדי לראות את התוצא כאן.