What Is a Loop?

In programming, there are some situations in which you want to do the same thing many times.

For instance, in Minecraft you might want to place 10 grass blocks. A loop is a block structure that allows you to easily repeat placing a grass block. In the Block editor, loops are green. There are different types of loops for different situations.

loops

You use loops to repeat code as many times as you want. When programmers talk about repeating code, they use many other words as well. All these words basically mean “repeat.” You will find them used, at times interchangeably, when you are learning about code.

  • iterate
  • iteration
  • iterative
  • repeat
  • repetition
  • repetitive
  • loop

Programmers use sentences like this: “Let’s iterate through the loop.” This means, “Run the same code many times, repeating something.”

What are some real-life examples of things you would repeat?

Walking is iteration… walking is repeating… walking is an action we do in a loop…

We don’t think much about it, but our bodies repeat many actions. Breathing, sleeping, eating, drinking, and walking are all actions that are repeated daily. Walking breaks down to repeating these steps:

.----.
|    |
|    v
|  Step 1 - "left foot forward"
|    |
|    v
|  Step 2 - "right foot forward"
|    |
|    v
'- REPEAT 

Other examples

What are some other examples of iteration or repeating in your daily life? What tasks and actions are composed of repeated steps? What are those steps?

Search the web for Ancient Roman aqueducts - Architects use repetition in their building designs.

Search the web for dog fetching ball on beach - Dogs love to play fetch as a repetitive activity.

Search the web for honeycomb - There are many repeated patterns found in nature.