What is a repetition structure?
A structure that makes the computer repeat included code as necessary
What are the two broad categories of loops?
Condition-controlled loops and count-controlled loops
What is a condition-controlled loop?
A loop that repeats while a Boolean condition is true
What is a count-controlled loop?
A loop that iterates a specific number of times
What is the syntax of a while loop in Python?
while condition:
statements
What is an iteration?
One execution of the body of a loop
What is a pretest loop?
A loop that tests its condition before performing an iteration (e.g., while loop)
What is an infinite loop?
A loop that never ends because the stopping condition is never met
How do you use a while loop as a count-controlled loop?
Use a counter variable with initialization, comparison, and update steps
What are the three actions in a count-controlled loop?
Initialization, comparison, and update
What is the syntax of a for loop in Python?
for variable in [val1, val2, …]:
statements
What is the purpose of the target variable in a for loop?
To reference each item in a sequence as the loop iterates
What does the range() function do?
Generates an iterable sequence of values for use in for loops
What arguments can range() take?
One argument: ending limit
Two arguments: start and end
Three arguments: start, end, and step
What is an accumulator variable?
A variable that keeps a running total inside a loop
What are augmented assignment operators?
Shorthand operators that update variables (e.g., +=, -=, *=, /=)
What is a sentinel?
A special value marking the end of a sequence of items
What is input validation?
Inspecting input before processing to ensure it is valid
What does GIGO stand for?
Garbage in, garbage out
How are input validation loops typically implemented?
With a while loop that repeats as long as input is invalid
What is a nested loop?
A loop contained inside another loop
How do you calculate total iterations in a nested loop?
Multiply iterations of the inner loop by iterations of the outer loop
What does the break statement do?
Immediately terminates a loop
What does the continue statement do?
Ends the current iteration early and moves to the next iteration