Chapter 9: Repeating with Loops

Learning Objectives

Upon completing all the content in this chapter, you should be able to do the following:

  1. Use iteration to repeat the execution of a code block
  2. Properly write for and while loops
  3. Use for and while loops in appropriate contexts

Key Terminology

Here is a list of key terms for this chapter broken down by the page the term first appears on. You should make note of these terms and their definitions.


  1. iteration
  2. DRY

for Loops

  1. for loop
  2. definite iteration
  3. initial expression
  4. loop condition
  5. update expression
  6. loop variable
  7. loop body

Breaking Down the for Statement

  1. infinite loop

The Accumulator Pattern

  1. pattern
  2. accumulator pattern
  3. accumulator

while Loops

  1. input validation

Choosing Which Loop to Use

  1. definite iteration
  2. indefinite iteration

Chapter Content