Loops in Scratch

June 07, 2021

Using Loops in Scratch

Scratch uses block code to make learning to code easier. There are many cool projects that can be done using Scratch and by learning the different types of loops leaves more room for creativity!



If we wanted to repeat a certain action in code multiple times, it would be best and more efficient to use a loop, that way the code is easier to read and there is less to write. Loops are great tools to use within code and projects to repeat an action multiple times. In the 'Control' section of block code, there are three types of loops: repeat x number of times, repeat until, and forever. Each type of loop has a different purpose and knowing what they do is important in writing code!



Repeat x Number of Times Loop

This loop is mainly used for repeating something a specific number of times. If we knew we wanted to ask 'Why?' three times, then this loop would be used to repeat that action three times. 



Outside of Scratch, this would be called a For Loop, which repeats code a set number of times just like Scratch!



Repeat Until Loop

This loop is useful for when something needs to happen before the loop should stop. If we wanted to keep asking 'Why?' until an answer was given, then this block would be used for that. 



Outside of Scratch, this would be called a While Loop, which repeats code until something is no longer true or false. This uses booleans, a data type in coding of 'True' or 'False', until it changes, then the code would be repeated. 



Forever Loop

This loop has no end, and is useful for repeating an action or a set of actions forever. This is the type of loop that is used in the video!



Conclusion



Understanding the different uses and abilities of each type of loop is useful for thinking of projects to do. Loops are an important part of coding and should be practiced often to better understand how to use it!