Lecture 16 — For Loops (Problems)

Restatement of the Basics

  • for loops tend to have a fixed number of iterations computed at the start of the loop.

  • while loops tend to have an indefinite termination, determined by the conditions of the data.

  • Most Python for loops are easily rewritten as while loops, but not vice-versa.

    • In other programming languages, for and while are almost interchangeable, at least in principle.

Overview of Today

  • Problems on for loops

  • Lecture Exercise

  • Review of Back Exam