A basic building block of all programs is to be able to repeat some code over and over again. Whether it is updating the bank balances of millions of customers each night, or sending email messages to thousands of people, programming involves instructing the computer to do many repetitive actions. So far we have learned basic programming commands (e.g. assigning values, printing) and, a way to control which statements are executed using the if
statement. In this lesson, we introduce loops (sometimes called repetition or iteration): a way to make a computer do the same thing (or similar things) over and over. For example, spell-checking every word in a document would be done with a loop. We will describe the two kinds of Python loops in this topic: while
loops and for
loops.
<Loops Presentation>