Loops – Scratch

In Scratch, there are 3 different kinds of loops: repeat loops, repeat-until loops and forever loops. The repeat loop is like the for-loop in Python, and the repeat-until loop is similar to the while loop in Python. The forever loop is an infinite loop. We give a sequence of Scratch examples to illustrate these three types of loops and their uses. The programs move a ball across the stage in a number of ways while illustrating the different uses of Scratch loops. To get started, draw a ball-like Scratch costume like this: image001 Program 1: A ball moves a fixed number of times. (with video)

Program 2: The ball moves until it reaches the end of the stage. (with video)

Program 3: A light bulb goes on and off. (with video)

Programs 4 and 5: A ball rolls back and forth, forever. (with video)

Program 6: Using nested loops for the forever moving circle. (with video)


Related problems and extensions students can explore

  • A ball rolls back and forth and its speed changes.  Explore changing color or size of the ball, possibly as the speed changes.
  • The ball changes direction: When the ball reaches the edge of the stage,  it bounces back in a different direction.
  • Two balls are moving inside the stage. How are collisions detected and handled?
  • Whenever a ball hits an edge of the stage, it splits into two balls that bounce off in different directions. Caution: this will produce many balls.