Deck 4: Repetition Structures

Full screen (f)
exit full mode
Question
In a flowchart,both the decision structure and the repetition structure use the diamond symbol to represent the condition that is tested.
Use Space or
up arrow
down arrow
to flip the card.
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
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
Question
In a nested loop,the inner loop goes through all of its iterations for each iteration of the outer loop.
Question
Reducing duplication of code is one of the advantages of using a loop structure.
Question
Functions can be called from statements in the body of a loop and loops can be called from within the body of a function.
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 variable used to keep a running total is called a(n)

A) accumulator
B) total
C) running total
D) summer
Question
__________ 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
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 valid data.
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 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 is not an augmented assignment operator?

A) *=
B) /=
C) +=
D) <=
Question
In Python,an infinite loop usually occurs when the computer accesses an incorrect memory address.
Question
The first line in a while loop is referred to as the condition clause.
Question
A while loop is called a pretest loop because the condition is tested after the loop has had one iteration.
Question
In order to draw an octagon with turtle graphics,you would need a loop that iterates eight times.
Question
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
Question
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.
Question
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.
Question
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
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 will be displayed after the following code is executed?
<strong>What will be displayed after the following code is executed?  </strong> A) counting counting counting counting B) counting Counting Counting Counting C) counting Counting D) counting Counting Counting <div style=padding-top: 35px>

A) counting counting counting counting
B) counting
Counting
Counting
Counting
C) counting
Counting
D) counting
Counting
Counting
Question
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
Question
A(n)__________ validation loop is sometimes called an error trap or an error handler.
Question
What will be displayed after the following code is executed?
What will be displayed after the following code is executed?    <div style=padding-top: 35px>
What will be displayed after the following code is executed?    <div style=padding-top: 35px>
Question
A(n)__________ is a special value that marks the end of a sequence of items.
Question
A(n)__________ total is a sum of numbers that accumulates with each iteration of the loop.
Question
In Python,you would use the __________ statement to write a count-controlled loop.
Question
The while loop is known as a(n)__________ loop because it tests the condition before performing an iteration.
Question
A(n)__________-controlled loop causes a statement or set of statements to repeat as long as the condition is true.
Question
What will be displayed after the following code is executed?
<strong>What will be displayed after the following code is executed?  </strong> A) 30 B) 25 C) 0 5 10 15 20 D) 5 10 15 <div style=padding-top: 35px>

A) 30
B) 25
C) 0 5 10 15 20
D) 5 10 15
Question
A(n)___________ structure causes a set of statements to execute repeatedly.
Question
What does the following program do?
<strong>What does the following program do?  </strong> 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. <div style=padding-top: 35px>

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.
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 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 does not include code inside the loop that makes the test condition false.
Question
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
Question
What will be displayed after the following code is executed?
What will be displayed after the following code is executed?    <div style=padding-top: 35px>
What will be displayed after the following code is executed?    <div style=padding-top: 35px>
Question
The ___________ function is a built-in function that generates a list of integer values.
Question
The following for loop iterates ___________ times to draw a square.
for x in range(4):
turtle.forward(200)
turtle.right(90)
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/41
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
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
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
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):
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
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
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.
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
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
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) <=
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
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
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
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?
<strong>What will be displayed after the following code is executed?  </strong> 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
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?
What will be displayed after the following code is executed?
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?
<strong>What will be displayed after the following code is executed?  </strong> 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?
<strong>What does the following program do?  </strong> 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
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
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?
What will be displayed after the following code is executed?
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)
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 41 flashcards in this deck.