Deck 5: Repetition Structures

Full screen (f)
exit full mode
Question
What type of loop structure repeats the code based on the value of the Boolean expression?

A) Condition-controlled loop
B) Number-controlled loop
C) Count-controlled loop
D) Boolean-controlled loop
Use Space or
up arrow
down arrow
to flip the card.
Question
The first line in the while loop is referred to as the condition clause.
Question
In Python, an infinite loop usually occurs when the computer accesses the wrong memory address.
Question
What are the values that the variable num contains through the iterations of the following for loop? for num in range(2, 9, 2)

A) 2, 3, 4, 5, 6, 7, 8, 9
B) 2, 5, 8
C) 2, 4, 6, 8
D) 1, 3, 5, 7, 9
Question
In Python, a comma-separated sequence of data items that are enclosed in a set of brackets is called a _____.

A) sequence
B) variable
C) value
D) list
Question
_____ is the process of inspecting data that has been input to a program to make sure it is valid before it is used in a computation.

A) Input validation
B) Correcting data
C) Data validation
D) Correcting input
Question
The variable used to keep the running total is called a(n) _____.

A) Accumulator
B) Total
C) running total
D) grand total
Question
What are the values that the variable num contains through the iterations of the following for loop? for num in range(4)

A) 1, 2, 3, 4
B) 0, 1, 2, 3, 4
C) 1, 2, 3
D) 0, 1, 2, 3
Question
Which of the following represents an example to calculate the sum of the numbers (accumulator)?

A) total + number = total
B) number += number
C) total += number
D) total = number
Question
What is the format for the while clause in Python?

A) while condition
B) while condition :
C) while condition statement
D) while condition : statement
Question
In flowcharting, the decision structure and the repetition structure both use the diamond symbol to represent the condition that is tested.
Question
What type of loop structure repeats the code a specific number of times?

A) Condition-controlled loop
B) Number-controlled loop
C) Count-controlled loop
D) Boolean-controlled loop
Question
What is the disadvantage of coding in one long sequence structure?

A) Duplicated code makes the program faster to write.
B) Writing a long sequence of statements is error prone.
C) If parts of the duplicated code have to be corrected, the correction has to be made many times.
D) It does not make use of decision structures.
Question
What is the structure that causes a statement or a set of statements to execute repeatedly?

A) Sequence
B) Decision
C) Module
D) Repetition
Question
The first input operation is called the _____, and its purpose is to get the first input value that will be tested by the validation loop.

A) priming read
B) first input
C) loop set read
D) loop validation
Question
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.

A) target variable
B) loop variable
C) for variable
D) count variable
Question
When will the following loop terminate? while keep_on_going != 999 :

A) When keep_on_going refers to a value less than 999
B) When keep_on_going refers to a value greater than 999
C) When keep_on_going refers to a value equal to 999
D) When keep_on_going refers to a value not equal to 999
Question
What is not an example of an augmented assignment operator?

A) *=
B) /=
C) -=
D) <=
Question
A better way to repeatedly perform an operation is to write the statements for the task once, and then place the statements in a loop that will repeat the statements as many times as necessary.
Question
Reducing duplication of code is one of the advantages of using a loop structure.
Question
The _______________ function is a built-in function that generates a list of integer values.
Question
A(n) _______________ validation loop is sometimes called an error trap or an error handler.
Question
In a nested loop, the inner loop goes through all of its iterations for every single iteration of an outer loop.
Question
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):
Question
A(n) _______________ total is a sum of numbers that accumulates with each iteration of a loop.
Question
To get the total number of iterations of a nested loop, multiply the number of iterations of all the loops.
Question
A(n) _______________ is a special value that marks the end of a sequence of items.
Question
In Python, you would use the _______________ statement to write a count-controlled loop.
Question
The acronym _______________ refers to the fact that the computer cannot tell the difference between good data and bad data.
Question
A(n) _______________ loop usually occurs when the programmer forgets to write code inside the loop that makes the test condition false.
Question
functions can be called from statements in the body of a loop, and loops can be called from the body of a function.
Question
The while loop is known as a(n) _______________ loop because it tests conditions before performing an iteration.
Question
The integrity of a program's output is only as good as the integrity of its input. for this reason the program should discard input that is invalid and prompt the user to enter correct data.
Question
A(n) _______________ structure causes a statement or set of statements to execute repeatedly.
Question
A(n) _______________-controlled loop causes a statement or set of statements to repeat as long as a condition ist.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/35
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 5: Repetition Structures
1
What type of loop structure repeats the code based on the value of the Boolean expression?

A) Condition-controlled loop
B) Number-controlled loop
C) Count-controlled loop
D) Boolean-controlled loop
A
2
The first line in the while loop is referred to as the condition clause.
False
3
In Python, an infinite loop usually occurs when the computer accesses the wrong memory address.
False
4
What are the values that the variable num contains through the iterations of the following for loop? for num in range(2, 9, 2)

A) 2, 3, 4, 5, 6, 7, 8, 9
B) 2, 5, 8
C) 2, 4, 6, 8
D) 1, 3, 5, 7, 9
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
5
In Python, a comma-separated sequence of data items that are enclosed in a set of brackets is called a _____.

A) sequence
B) variable
C) value
D) list
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
6
_____ is the process of inspecting data that has been input to a program to make sure it is valid before it is used in a computation.

A) Input validation
B) Correcting data
C) Data validation
D) Correcting input
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
7
The variable used to keep the running total is called a(n) _____.

A) Accumulator
B) Total
C) running total
D) grand total
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
8
What are the values that the variable num contains through the iterations of the following for loop? for num in range(4)

A) 1, 2, 3, 4
B) 0, 1, 2, 3, 4
C) 1, 2, 3
D) 0, 1, 2, 3
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following represents an example to calculate the sum of the numbers (accumulator)?

A) total + number = total
B) number += number
C) total += number
D) total = number
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
10
What is the format for the while clause in Python?

A) while condition
B) while condition :
C) while condition statement
D) while condition : statement
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
11
In flowcharting, the decision structure and the repetition structure both use the diamond symbol to represent the condition that is tested.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
12
What type of loop structure repeats the code a specific number of times?

A) Condition-controlled loop
B) Number-controlled loop
C) Count-controlled loop
D) Boolean-controlled loop
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
13
What is the disadvantage of coding in one long sequence structure?

A) Duplicated code makes the program faster to write.
B) Writing a long sequence of statements is error prone.
C) If parts of the duplicated code have to be corrected, the correction has to be made many times.
D) It does not make use of decision structures.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
14
What is the structure that causes a statement or a set of statements to execute repeatedly?

A) Sequence
B) Decision
C) Module
D) Repetition
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
15
The first input operation is called the _____, and its purpose is to get the first input value that will be tested by the validation loop.

A) priming read
B) first input
C) loop set read
D) loop validation
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
16
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.

A) target variable
B) loop variable
C) for variable
D) count variable
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
17
When will the following loop terminate? while keep_on_going != 999 :

A) When keep_on_going refers to a value less than 999
B) When keep_on_going refers to a value greater than 999
C) When keep_on_going refers to a value equal to 999
D) When keep_on_going refers to a value not equal to 999
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
18
What is not an example of an augmented assignment operator?

A) *=
B) /=
C) -=
D) <=
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
19
A better way to repeatedly perform an operation is to write the statements for the task once, and then place the statements in a loop that will repeat the statements as many times as necessary.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
20
Reducing duplication of code is one of the advantages of using a loop structure.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
21
The _______________ function is a built-in function that generates a list of integer values.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
22
A(n) _______________ validation loop is sometimes called an error trap or an error handler.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
23
In a nested loop, the inner loop goes through all of its iterations for every single iteration of an outer loop.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
24
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):
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
25
A(n) _______________ total is a sum of numbers that accumulates with each iteration of a loop.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
26
To get the total number of iterations of a nested loop, multiply the number of iterations of all the loops.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
27
A(n) _______________ is a special value that marks the end of a sequence of items.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
28
In Python, you would use the _______________ statement to write a count-controlled loop.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
29
The acronym _______________ refers to the fact that the computer cannot tell the difference between good data and bad data.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
30
A(n) _______________ loop usually occurs when the programmer forgets to write code inside the loop that makes the test condition false.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
31
functions can be called from statements in the body of a loop, and loops can be called from the body of a function.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
32
The while loop is known as a(n) _______________ loop because it tests conditions before performing an iteration.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
33
The integrity of a program's output is only as good as the integrity of its input. for this reason the program should discard input that is invalid and prompt the user to enter correct data.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
34
A(n) _______________ structure causes a statement or set of statements to execute repeatedly.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
35
A(n) _______________-controlled loop causes a statement or set of statements to repeat as long as a condition ist.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 35 flashcards in this deck.