Gaddis Python 4e Chapter 04
Gaddis Python 4e Chapter 04
Repetition
Structures
Topics
• Introduction to Repetition Structures
• The while Loop: a Condition-Controlled Loop
• The for Loop: a Count-Controlled Loop
• Calculating a Running Total
• Sentinels
• Input Validation Loops
• Nested Loops
• Turtle Graphics: Using Loops to Draw Designs
Infinite Loops
• Loops must contain within themselves
a way to terminate
• Something inside a while loop must
eventually make the condition false
• Infinite loop: loop that does not have a
way of stopping
• Repeats until program is interrupted
• Occurs when programmer forgets to include
stopping code in the loop