CH 4 Flashcards

1
Q

T/F | Reducing duplication of code is one of the advantages of using a loop structure.

A

T

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

T/F | 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.

A

T

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

T/F | In Python, an infinite loop usually occurs when the computer accesses the wrong memory address.

A

F

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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):

A

T

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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, 4, 6, 8

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

a variable used to keep a running total is called

A

accumulator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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 that is an integer
(D) When keep_on_going refers to a value not equal to 999
(E) When keep_on_going refers to a value equal to 999

A

(E) When keep_on_going refers to a value equal to 999

How well did you know this?
1
Not at all
2
3
4
5
Perfectly