Chapter 6. Conditionals and Loops
true, do this. Otherwise, do that.” For example, if you do your homework, you can have ice cream, but if you don’t do your homework, you don’t get the ice cream. A loop says, “As long as something is
true, keep doing this.” For example, as long as you are thirsty, keep drinking water.
Conditionals and loops are powerful concepts that are key to any sophisticated program. They are called control structures because they allow you to control which parts of your code are executed when and how often they’re executed, based on certain conditions you define.