Programming Repeated Steps
Python programs are made up of a series of statements that execute in order.
Loops allow you to repeat a set of statements while a particular expression evaluates to True.
Imagine that you want to print all the positive integers less than 10. You wouldn’t really want to do this:
Instead you could use a while loop with a variable counter. This is very useful if you want to print all the positive integers less than 1 million…
The for loop lets you to iterate through a series of values. We’ll be learning more about lists in Module 3.
Imagine you want to print all possible combinations of two lists of numbers.
It’s often useful to combine loops with functions. For example: convert a list of temperatures from Fahrenheit to Celsius:
The break keyword is used to break out of a loop. It can be useful in situations where the work inside a loop can stop prematurely, or because the loop is infinite.