Deck 4: Repetition Structures

Full screen (f)
exit full mode
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
Use Space or
up arrow
down arrow
to flip the card.
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
The variable used to keep the running total is called a(n) _____.

A) Accumulator
B) Total
C) running total
D) grand total
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
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
The first line in the while loop is referred to as the condition clause.
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
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
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
_____ 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
In Python, an infinite loop usually occurs when the computer accesses the wrong memory address.
Question
Reducing duplication of code is one of the advantages of using a loop structure.
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
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
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 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
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
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
In flowcharting, the decision structure and the repetition structure both use the diamond symbol to represent the condition that is tested.
Question
A(n) _______________-controlled loop causes a statement or set of statements to repeat as long as a condition is true.
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) _______________ is a special value that marks the end of a sequence of items.
Question
The _______________ function is a built-in function that generates a list of integer values.
Question
A(n) _______________ loop usually occurs when the programmer forgets to write code inside the loop that makes the test condition false.
Question
A(n) _______________ total is a sum of numbers that accumulates with each iteration of a 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
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
A(n) _______________ structure causes a statement or set of statements to execute repeatedly.
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) _______________ 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.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/34
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 4: Repetition Structures
1
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
C
2
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
D
3
The variable used to keep the running total is called a(n) _____.

A) Accumulator
B) Total
C) running total
D) grand total
A
4
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
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
5
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 34 flashcards in this deck.
Unlock Deck
k this deck
6
The first line in the while loop is referred to as the condition clause.
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
7
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 34 flashcards in this deck.
Unlock Deck
k this deck
8
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 34 flashcards in this deck.
Unlock Deck
k this deck
9
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 34 flashcards in this deck.
Unlock Deck
k this deck
10
_____ 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 34 flashcards in this deck.
Unlock Deck
k this deck
11
In Python, an infinite loop usually occurs when the computer accesses the wrong memory address.
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
12
Reducing duplication of code is one of the advantages of using a loop structure.
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
13
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 34 flashcards in this deck.
Unlock Deck
k this deck
14
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 34 flashcards in this deck.
Unlock Deck
k this deck
15
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 34 flashcards in this deck.
Unlock Deck
k this deck
16
What is not an example of an augmented assignment operator?

A) *=
B) /=
C) -=
D) <=
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
17
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 34 flashcards in this deck.
Unlock Deck
k this deck
18
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 34 flashcards in this deck.
Unlock Deck
k this deck
19
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 34 flashcards in this deck.
Unlock Deck
k this deck
20
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 34 flashcards in this deck.
Unlock Deck
k this deck
21
A(n) _______________-controlled loop causes a statement or set of statements to repeat as long as a condition is true.
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
22
In Python, you would use the _______________ statement to write a count-controlled loop.
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
23
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 34 flashcards in this deck.
Unlock Deck
k this deck
24
A(n) _______________ is a special value that marks the end of a sequence of items.
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
25
The _______________ function is a built-in function that generates a list of integer values.
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
26
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 34 flashcards in this deck.
Unlock Deck
k this deck
27
A(n) _______________ total is a sum of numbers that accumulates with each iteration of a loop.
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
28
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 34 flashcards in this deck.
Unlock Deck
k this deck
29
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 34 flashcards in this deck.
Unlock Deck
k this deck
30
The while loop is known as a(n) _______________ loop because it tests conditions before performing an iteration.
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
31
A(n) _______________ structure causes a statement or set of statements to execute repeatedly.
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
32
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 34 flashcards in this deck.
Unlock Deck
k this deck
33
A(n) _______________ validation loop is sometimes called an error trap or an error handler.
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
34
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 34 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 34 flashcards in this deck.