This course is part of our College Credit Program, designed to help you earn college credit while mastering valuable skills. If you're interested in pursuing college credit, click here to learn more.
Loops in Programming
A loop is a code block that runs a set of statements while a given condition is true. Loops are often used for performing repetitive tasks. For example:
- The software on a phone repeatedly checks to see if the phone is idle. Once the time set by a user is reached, the phone is locked.
- Loops can also be used for iterating over lists, such as student names in a roster, and printing the names one at a time.
In this chapter, two types of loops are introduced:
- For Loop
- While Loop
This chapter also introduces the break and continue statements, which are used to control a loop's execution.