Filters
Question type

Study Flashcards

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) True
B) False

Correct Answer

verifed

verified

True

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

E) A) and C)
F) A) and B)

Correct Answer

verifed

verified

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

E) B) and C)
F) None of the above

Correct Answer

verifed

verified

A variable used to keep a running total is called a(n)


A) accumulator
B) total
C) running total
D) summer

E) None of the above
F) All of the above

Correct Answer

verifed

verified

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.

A) True
B) False

Correct Answer

verifed

verified

True

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.

A) True
B) False

Correct Answer

verifed

verified

Functions can be called from statements in the body of a loop and loops can be called from within the body of a function.

A) True
B) False

Correct Answer

verifed

verified

A(n)__________ validation loop is sometimes called an error trap or an error handler.

Correct Answer

verifed

verified

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

E) A) and D)
F) A) and C)

Correct Answer

verifed

verified

In Python,an infinite loop usually occurs when the computer accesses an incorrect memory address.

A) True
B) False

Correct Answer

verifed

verified

What will be displayed after the following code is executed? 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

E) B) and C)
F) A) and B)

Correct Answer

verifed

verified

A(n)__________ total is a sum of numbers that accumulates with each iteration of the loop.

Correct Answer

verifed

verified

The following for loop iterates ___________ times to draw a square. for x in range(4): turtle.forward(200) turtle.right(90)

Correct Answer

verifed

verified

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

E) B) and D)
F) C) and D)

Correct Answer

verifed

verified

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

E) B) and C)
F) A) and D)

Correct Answer

verifed

verified

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

E) A) and B)
F) All of the above

Correct Answer

verifed

verified

What will be displayed after the following code is executed? total =0 =0 for count in range (4,6) : (4,6) : \quad total += += count \quad print (total)


A) 4
9
B) 4
5
6
C) 4
5
D) 9

E) B) and C)
F) A) and D)

Correct Answer

verifed

verified

In a nested loop,the inner loop goes through all of its iterations for each iteration of the outer loop.

A) True
B) False

Correct Answer

verifed

verified

True

A while loop is called a pretest loop because the condition is tested after the loop has had one iteration.

A) True
B) False

Correct Answer

verifed

verified

In a flowchart,both the decision structure and the repetition structure use the diamond symbol to represent the condition that is tested.

A) True
B) False

Correct Answer

verifed

verified

Showing 1 - 20 of 41

Related Exams

Show Answer