Python Chapter 03 multiple choice
____ is the format operator.
%
What will the following loop print on the screen? for count in range(4): print count,
0 1 2 3
A ____ must follow the else in an if-else statement.
:
In Python, a ____ ends the loop header.
:
The ____ comparison operator is used for equality.
==
The ____ data type consists of only two data values—true and false.
Boolean
To halt a loop that appears to be hung during testing, type ____ in the terminal window or in the IDLE shell.
Control+c
The logical operators have a higher precedence than the ____ operator(s).
assignment
Using the ____ statement within the body of a loop will cause an exit from the loop.
break
The not operator has a lower precedence than the ____ operator(s).
comparison
Errors to rule out during testing the while loop include an incorrectly initialized loop control variable, failure to update this variable correctly within the loop, and failure to test it correctly in the ____ condition.
continuation
Loops that count through a range of numbers are also called ____ loops.
count-controlled
The first line of code in a loop is sometimes called the loop ____.
header
In a loop, each repetition of the action is known as a pass or a(n) ____.
iteration
Off-by-one errors in loops are ____ errors.
logic
The condition in the if-else statement ____ be a Boolean expression.
must
The if statement is also called a ____ selection statement.
one-way
The ____ operator returns False if and only if both of its operands are false, and returns True otherwise.
or
Python's ____ module supports several ways to generate random numbers.
random
An example of conditional iteration is when a program's input loop accepts values until the user enters a special value or a ____ terminates the input.
sentinel
In the expression (A or B), if A is true, then so is the expression, and there is no need to evaluate B. This approach, in which evaluation stops as soon as possible, is called ____ evaluation.
short-circuit
In ____ format, numbers and other information are aligned in columns that can be either left-justified or right-justified.
tabular
The ____ argument of Python's range function specifies a step value.
third
"%6s" % "four" right-justifies the string by padding it with ____.
two spaces to its left
The if-else statement is also called a ____ selection statement
two-way