Deck 4: Repetition Structures
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/41
Play
Full screen (f)
Deck 4: Repetition Structures
1
In a flowchart,both the decision structure and the repetition structure use the diamond symbol to represent the condition that is tested.
True
2
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
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
C
3
A(n)__________ structure is a structure that causes a statement or a set of statements to execute repeatedly.
A) sequence
B) decision
C) module
D) repetition
A) sequence
B) decision
C) module
D) repetition
D
4
In a nested loop,the inner loop goes through all of its iterations for each iteration of the outer loop.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
5
Reducing duplication of code is one of the advantages of using a loop structure.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
6
Functions can be called from statements in the body of a loop and loops can be called from within the body of a function.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
7
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):
for num in range(4):
for num in range(1,5):
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
8
A variable used to keep a running total is called a(n)
A) accumulator
B) total
C) running total
D) summer
A) accumulator
B) total
C) running total
D) summer
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
9
__________ 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.
A) Input validation
B) Correcting data
C) Data validation
D) Correcting input
A) Input validation
B) Correcting data
C) Data validation
D) Correcting input
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
10
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 valid data.
For this reason,the program should discard input that is invalid and prompt the user to enter valid data.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
11
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
A) condition-controlled loop
B) number-controlled loop
C) count-controlled loop
D) Boolean-controlled loop
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
12
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
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 41 flashcards in this deck.
Unlock Deck
k this deck
13
Which of the following is not an augmented assignment operator?
A) *=
B) /=
C) +=
D) <=
A) *=
B) /=
C) +=
D) <=
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
14
In Python,an infinite loop usually occurs when the computer accesses an incorrect memory address.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
15
The first line in a while loop is referred to as the condition clause.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
16
A while loop is called a pretest loop because the condition is tested after the loop has had one iteration.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
17
In order to draw an octagon with turtle graphics,you would need a loop that iterates eight times.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
18
What type of loop structure repeats the code based on the value of Boolean expression?
A) condition-controlled loop
B) number-controlled loop
C) count-controlled loop
D) Boolean-controlled loop
A) condition-controlled loop
B) number-controlled loop
C) count-controlled loop
D) Boolean-controlled loop
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
19
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.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
20
A good 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 as many times as necessary.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
21
In Python,a comma-separated sequence of data items that are enclosed in a set of brackets is called
A) sequence
B) variable
C) value
D) list
A) sequence
B) variable
C) value
D) list
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
22
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
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 41 flashcards in this deck.
Unlock Deck
k this deck
23
What will be displayed after the following code is executed?

A) counting counting counting counting
B) counting
Counting
Counting
Counting
C) counting
Counting
D) counting
Counting
Counting

A) counting counting counting counting
B) counting
Counting
Counting
Counting
C) counting
Counting
D) counting
Counting
Counting
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
24
The first 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
A) priming read
B) first input
C) loop set read
D) loop validation
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
25
A(n)__________ validation loop is sometimes called an error trap or an error handler.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
26
What will be displayed after the following code is executed?




Unlock Deck
Unlock for access to all 41 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 41 flashcards in this deck.
Unlock Deck
k this deck
28
A(n)__________ total is a sum of numbers that accumulates with each iteration of the loop.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
29
In Python,you would use the __________ statement to write a count-controlled loop.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
30
The while loop is known as a(n)__________ loop because it tests the condition before performing an iteration.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
31
A(n)__________-controlled loop causes a statement or set of statements to repeat as long as the condition is true.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
32
What will be displayed after the following code is executed?

A) 30
B) 25
C) 0 5 10 15 20
D) 5 10 15

A) 30
B) 25
C) 0 5 10 15 20
D) 5 10 15
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
33
A(n)___________ structure causes a set of statements to execute repeatedly.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
34
What does the following program do?

A) It accepts 4 test scores for 3 students and outputs the average of the 12 scores.
B) It accepts 3 test scores for each of 3 students and outputs the average for each student.
C) It accepts 4 test scores for 2 students, then averages and outputs all the scores.
D) It accepts one test score for each of 3 students and outputs the average of the 3 scores.

A) It accepts 4 test scores for 3 students and outputs the average of the 12 scores.
B) It accepts 3 test scores for each of 3 students and outputs the average for each student.
C) It accepts 4 test scores for 2 students, then averages and outputs all the scores.
D) It accepts one test score for each of 3 students and outputs the average of the 3 scores.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
35
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
A) target variable
B) loop variable
C) for variable
D) count variable
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
36
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 41 flashcards in this deck.
Unlock Deck
k this deck
37
A(n)___________ loop usually occurs when the programmer does not include code inside the loop that makes the test condition false.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
38
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?
A) total + number = total
B) number += number
C) total += number
D) total = number
A) total + number = total
B) number += number
C) total += number
D) total = number
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
39
What will be displayed after the following code is executed?




Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
40
The ___________ function is a built-in function that generates a list of integer values.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
41
The following for loop iterates ___________ times to draw a square.
for x in range(4):
turtle.forward(200)
turtle.right(90)
for x in range(4):
turtle.forward(200)
turtle.right(90)
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck