Chapter 4 Flashcards
A __________ -controlled loop uses a true/false condition to control the number of
times that it repeats.
sentinel loop
A __________ -controlled loop repeats a specific number of times.
count-controlled loop
Each repetition of a loop is known as a(n) __________.
an iteration
The while loop is a __________ type of loop.
pretest loop
A(n) __________ loop has no way of ending and repeats until the program is interrupted
infinite
The -= operator is an example of a(n) __________ operator.
The -= operator is an example of a(n) __________ operator.
A(n) __________ variable keeps a running total.
accumulator
A(n) __________ is a special value that signals when there are no more items from a list of items to be processed. This value cannot be mistaken as an item from the list.
sentinel
GIGO stands for
garbage in, garbage out
The integrity of a program’s output is only as good as the integrity of the program’s
input
The input operation that appears just before a validation loop is known as the
priming read
Validation loops are also known as
error traps
What is a repetition structure?
A structure that causes a section of code to repeat
What is a condition-controlled loop?
A loop that uses a true/false condition to control the number of times that it repeats
What is a count-controlled loop?
A loop that repeats a specific number of times
Validation loops are also known as__
error traps
The input operation that appears just before a validation loop is known as the
the priming read
What are the values that the variable num contains through the iterations of the following for loop?
for num in range(4):
0,1,2,3
What are the values that the variable num contains through the iterations of the following for loop?
for num in range(2, 9, 2):
2,4,6,8
What are the values that the variable num contains through the iterations of the following for loop?
for num in range(10, 1, -1):
How many numbers of loop iterations will both of the following for clauses generate?
for num in range(4):
Ans:
for num in range(1, 5):
Ans:
What will be displayed after the following code is executed?
total = 0
for count in range(1,4):
total += count
print(total)
Ans:
What will be displayed after the following code is executed?
count = 4
while count < 12:
print("counting") count = count + 2
x = 99
while x > 0:
print (x)
ANS: