Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

Summary

In this lesson, you learned that:

  • Something that repeats in a task is a pattern. Wherever there's a pattern, a loop can make the program shorter.
  • A loop such as Repeat 3 times carries out the blocks in its mouth as many times as its number says. Carrying them out once is a pass through the loop.
  • On every pass, all the blocks inside are carried out from top to bottom, and only then does the next pass start.
  • Blocks under a loop are carried out once, after all its passes.
  • Inside a loop, the order of the blocks matters. In A Bone on Every Tile, Move forward had to come before Pick up bone, so that the dog first stepped onto the bone. Go through the first and the last pass in your head.
  • A loop inside another loop is a nested loop. The inner loop runs all the way through on every pass of the outer one.
  • Two kinds of bugs are common in loops: the wrong number of passes, and a block in the wrong place, inside the loop instead of under it or the other way around.

Time to practice. The stairs are back, but each stair is now three tiles wide, and there's a bone on each of those tiles. The last bone lies just above the top stair.

In the next lesson, Checkpoint: A Walk in the Park, you'll build whole programs on your own with what you know now.

Instructions

  1. 1

    Pick up all ten bones. First work out what the dog does on one stair, and then where the last bone is.

  2. 2

    Use at most 9 blocks. You'll need a nested loop.

Back

11/11

  1. 1. Repeating Moves
  2. 2. Loops
  3. 3. Stairs
  4. 4. After the Loop
  5. 5. Quiz: Pass by Pass
  6. 6. A Bone on Every Tile
  7. 7. Around the Flower Bed
  8. 8. A Loop in a Loop
  9. 9. A Bug in a Loop
  10. 10. Quiz: A Bug in a Nested Loop
  11. 11. Summary
Next

Try it yourself

Do this exercise right here in your browser. No account needed.