1/28
Comprehensive vocabulary flashcards defining key terminology, loop types, control statements, and logic mechanisms from Chapter 4 (Repetition Structures).
Repetition structure
A programming structure that makes the computer repeat included code as necessary, avoiding the need to duplicate code.
Condition-controlled loop
A category of loop that uses a true/false condition to control the number of times it iterates.
Count-controlled loop
A category of loop that repeats a specific number of times.
while loop
A condition-controlled loop that repeats statements as long as a tested condition evaluates to true.
Iteration
One execution of the body of a loop.
Pretest loop
A loop that tests its condition before performing an iteration; it will never execute if the condition is false to begin with.
Infinite loop
A loop that lacks a mechanism to stop and continues executing until the program is interrupted.
Counter variable
A variable assigned a unique value during each iteration of a loop, used to count the number of times the loop iterates.
Initialization (count-controlled loop)
The action of setting the counter variable to a suitable starting value before the loop begins.
Comparison (count-controlled loop)
The action of evaluating the counter variable against a suitable ending value to determine whether the loop should iterate.
Update (count-controlled loop)
The action performed during each loop iteration that modifies the counter variable with a new value.
Single-line while loop
A while loop written entirely on one line when there is only one statement in its body.
for loop
A Python statement designed to write a count-controlled loop that iterates once for each item in a sequence of data items.
Target variable
The variable in a for loop that is the target of assignment at the beginning of each iteration.
Iterable
An object that contains a sequence of values that can be iterated over, such as the object returned by the range function.
range function
A built-in function that simplifies writing a for loop by generating an iterable sequence of integer values.
Step value
The optional third argument in the range function that specifies the increment or decrement between each consecutive value in the sequence.
Running total
A cumulative sum of a series of numbers that is accumulated across iterations of a loop.
Accumulator
A variable used in a program to store and accumulate numbers, referencing the total sum at the end of the loop.
Augmented assignment operators
Special shorthand operators (such as +=, -=, *=, /=, and %=) designed for assignment statements where the variable on the left of the = operator also appears on the right side.
Sentinel
A distinctive value that marks the end of a sequence of items, signaling the program to terminate the loop.
GIGO
An acronym standing for 'garbage in, garbage out,' meaning that if a user inputs bad data, the program will produce bad output.
Input validation
The process of inspecting data before it is processed by a program to ensure invalid or bad input is rejected.
Walrus operator
The assignment expression operator (:=) that allows combining a priming read with an input validation loop header.
Nested loop
A loop that is placed inside the body of another loop.
Total iterations of a nested loop
The total number of loop cycles calculated by number of iterations of inner loop×number of iterations of outer loop.
break statement
A statement that immediately causes a loop to terminate execution.
continue statement
A statement that ends the current iteration early, causing the loop to skip the remainder of its body and move to the next iteration.
else clause (with loops)
An optional block that executes after a while or for loop terminates normally, but does not execute if the loop is exited via a break statement.