Loops
By Sanjay and Arvind Seshan
BEGINNER PROGRAMMING LESSONS
LESSON OBJECTIVES
1. Learn how to repeat an action
2. Learn how to use Loop Blocks
© [Link], 2016, (Last edit: 7/26/2016) 2
REPEATING AN ACTION
Let’s say we want the robot to repeat
an action over and over again.
Would you just copy the block
multiple times?
Sure, that could work!
What if I want to repeat that block
forever?
Now what?
© [Link], 2016, (Last edit: 7/26/2016) 3
LOOPS
Loops make repeating a task multiple
times easy
The added benefit is that a loop can end
whenever you want (a specific number
of times, run forever, a specific
condition, etc)
© [Link], 2016, (Last edit: 7/26/2016) 4
LOOP CHALLENGE
Challenge: Write a program to go around a box once.
The simple way is to code it like this:
Use a loop to improve the code
© [Link], 2016, (Last edit: 7/26/2016) 5
LOOP CHALLENGE SOLUTION
Run 4
times
© [Link], 2016, (Last edit: 7/26/2016) 6
CREDITS
• This tutorial was created by Sanjay Seshan and Arvind Seshan
• More lessons are available at [Link]
This work is licensed under a Creative Commons Attribution-
NonCommercial-ShareAlike 4.0 International License.
© [Link], 2016, (Last edit: 7/26/2016) 7