Topic Three Flashcards
A ________ controlled loop uses a true/false condition to control the number of times that it repeats.
a. Boolean
b. condition
c. decision
d. count
b. condition
A _________ controlled loop repeats a specific number of times
a. Boolean
b. condition
c. decision
d. count
d. count
Each repetition of a loop is known as a (n) ___________
a. cycle
b. revolution
c. orbit
d. iteration
d. iteration
The while loop is a _________ type of loop
a. pretest
b. no-test
c. prequalified
d. post-iterative
a. pretest
A (n) _________ loop has no way of ending and repeats until the program is interrupted
a. indeterminate
b. interminable
c. infinite
d. timeless
c. infinite
The -= operator is an example of a (n) ____________ operator
a. relational
b. augmented assignment
c. complex assignment
d. reverse assignment
b. augmented assignment
A (n) _________ variable keeps a running total
a. sentinel
b. sum
c. total
d. accumulator
d. 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.
a. sentinel
b. flag
c. signal
d. accumulator
a. sentinel
GIGO stands for _____________ .
a. great input, great output
b. garbage in, garbage out
c. GIGahertz Output
d. GIGabyte Operation
b. garbage in, garbage out
The integrity of a program’s output is only as good as the integrity of the program’s __________
a. compiler
b. programming language
c. input
d. debugger
c. input
The input operation that appears just before a validation loop is known as the ___________
a. prevalidation read
b. primordial read
c. initialization read
d. priming read
d. priming read
Validation loops are also known as _______________
a. error traps
b. doomsday loops
c. error avoidance loops
d. defensive loops
a. error traps
Reducing the duplication of code is one of the advantages of using a loop structure.
True or False
True
In a flowchart, both the decision structure and the repetition structure use the diamond symbol to represent the condition that is tested.
True or False
True
Both of the following for clauses would generate the same number of loop iterations.
for num in range(4):
for num in range(1, 5):
True or False
True
To get the total number of iterations in a nested loop, add the number of iterations in the inner loop to the number in the outer loop.
True or False
False
What type of loop structure repeats the code based on the value of Boolean expression?
number-controlled loop
Boolean-controlled loop
count-controlled loop
condition-controlled loop
condition-controlled loop
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, 5, 8
2, 3, 4, 5, 6, 7, 8, 9
1, 3, 5, 7, 9
2, 4, 6, 8
2, 4, 6, 8
__________ is the process of inspecting data that has been input into a program in order to ensure that the data is valid before it is used in a computation.
Input validation
Data validation
Correcting data
Correcting input
Input validation
When will the following loop terminate?
while keep_on_going != 999:
a. when keep_on_going refers to a value greater than 999
b. when keep_on_going refers to a value not equal to 999
c. when keep_on_going refers to a value less than 999
d. when keep_on_going refers to a value equal to 999
d. when keep_on_going refers to a value equal to 999
In Python, the variable in the for clause is referred to as the __________ because it is the target of an assignment at the beginning of each loop iteration.
count variable
loop variable
target variable
for variable
target variable
Which of the following represents an example to calculate the sum of numbers (that is, an accumulator), given that the number is stored in the variable number and the total is stored in the variable total?
total + number = total
number += number
total = number
total += number
total += number
What will be displayed after the following code is executed?
count = 4
while count < 12:
print(“counting”, end= ‘ ‘)
count = count + 2
counting counting counting
counting counting counting counting
counting counting counting counting counting
counting counting
counting counting counting counting
What will be displayed after the following code is executed?
for num in range(0, 20, 5):
num += num
print(num)
a. 30
b. 5 10 15
c. 25
d. 0 5 10 15 20
30