Chapter 5 (Loops) Flashcards
One set of instructions that operate on multiple, separate sets of data
Loop
This keyword starts the loop body and precedes any statements that execute when the tested condition is True.
While
What keyword ends the “while” loop structure?
Endwhile
What does the loop control variable do?
Manages the number of repetitions a loop performs.
What are the 3 actions that should occur when using a loop control variable:
- INITIALIZE the variable before entering the loop.
- TEST the variable to see if the result is True, before entering the loop.
- Set conditions which allow the variable to be ALTERed within the body of the loop.
What is the significance of making the loop control variable alterable within the body of the loop?
It allows the tested condition to return as false, which will make the loop end (eventually).
Initializing the loop control variable is essentially providing the loop with a ______ ____.
starting value
The 3 separate actions concerning a loop control variable prevents ______ _____.
infinite loops
What are 2 common loop control variable types?
- a counter
2. a sentinel value
Sentinel values as a loop control variable are used to create what type of loop?
indefinite
These loops execute a predetermined number of times.
Definite loops
A counter is any numeric value that counts the number of times an event has occurred. What is the best number to start a counted loop at?
0
This naturally lends itself to definite loops with a starting value/counter of 0
array manipulation
Is starting a counter loop at 0 necessary?
No, but it is encouraged.
Counted loops are a program that track the number of loop repetitions by counting them. What is another name for counted loops?
Counter-controlled loops.
These loops perform a varying amount of times.
Indefinite loops
<> is a ______ symbol
placeholder
What is the name of this placeholder symbol: <>
Not-equal-to-operator
Evaluates as True when its operands are not equivalent/identical
<>
What are loops within loops?
Nested loops
The nested loop contains:
At least 1 outer loop, and at least 1 inner loop
An inner loop goes through all of its iterations each time that an outer loop goes through how many iterations?
One
# of inner loop iterations * # of outer loop iterations The above is...
the formula for the total number of iterations executed by a nested loop.
Another phrase for the “for statement”
For loop