Lesson 16. Repeating tasks with loops
After reading lesson 16, you’ll be able to
- Understand what it means for a line of code to repeat execution
- Write a loop in a program
- Repeat actions a certain number of times
The programs you’ve seen so far have statements that are executed once, at most. In the preceding unit, you learned to add decision points in your programs, which can break up the flow by making the program react to input. The decision points are governed by conditional statements that may cause your program to take a detour to execute other lines of code if a certain condition holds.
These kinds of programs still have a type of linearity to them; statements are executed top to bottom, and a statement can be executed either zero times ...
Get Get Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.