Chapter 3

24 July 2022
4.7 (114 reviews)
39 test answers

Unlock all answers in this set

Unlock answers (35)
question
The Python language is not sensitive to block structuring of code.
answer
F
question
The if statement causes one or more statements to execute only when a Boolean expression is true.
answer
T
question
Python allows you to compare strings, but it is not case sensitive.
answer
F
question
Nested decision statements are one way to test more than one condition.
answer
T
question
Python uses the same symbols for the assignment operator as for the equality operator.
answer
F
question
The not operator is a unary operator which must be used in a compound expression.
answer
F
question
Short -circuit evaluation is only performed with the not operator.
answer
F
question
Expressions that are tested by the if statement are called Boolean expressions.
answer
T
question
Decision structures are also known as selection structures.
answer
T
question
An action in a single alternative decision structure is performed only when the condition is true.
answer
T
question
The following statement will check to see if the turtle's pen color is 'green': if turtle.pencolor() = 'green'
answer
F
question
A(n) __________ structure is a logical design that controls the order in which a set of statements execute. a. function b. control c. sequence d. iteration
answer
b. control
question
The decision structure that has two possible paths of execution is known as a. single alternative b. double alternative c. dual alternative d. two alternative
answer
c. dual alternative
question
Multiple Boolean expressions can be combined by using a logical operator to create __________ expressions. a. sequential b. logical c. compound d. mathematical
answer
c. compound
question
When using the __________ logical operator, one or both of the subexpressions must be true for the compound expression to be true. a. or b. and c. not d. maybe
answer
a. or
question
Which logical operators perform short-circuit evaluation? a. or, not b. not, and c. or, and d. and, or, not
answer
c. or, and
question
Which of the following is the correct if clause to determine whether y is in the range 10 through 50, inclusive? a. if 10 < y or y > 50: b. if 10 > y and y < 50: c. if y >= 10 and y <= 50: d. if y >= 10 or y <= 50:
answer
c. if y >= 10 and y <= 50:
question
A Boolean variable can reference one of two values which are a. yes or no b. True or False c. T or F d. Y or N
answer
b. True or False
question
What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8? x < y or z > x a. True b. False c. 8 d. 5
answer
b. False
question
What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8? x < y and z > x a. True b. False c. 8 d. 5
answer
b. False
question
What is the result of the following Boolean expression, given that x = 5, y = 3, and z= 8? not (x < y or z > x) and y < z a. True b. False c. 8 d. 5
answer
b. False
question
What does the following expression mean? x <= y a. x is less than y b. x is less than or equal to y c. x is greater than y d. x is greater than or equal to y
answer
b. x is less than or equal to y
question
Which of the following is the correct if clause to determine whether choice is anything other than 10? a. if choice != 10: b. if choice != 10 c. if choice <> 10: d. if not(choice < 10 and choice > 10):
answer
a. if choice != 10:
question
When using the __________ logical operator, both subexpressions must be true for the compound expression to be true. a. or b. and c. not d. either or or and
answer
b. and
question
n Python the __________ symbol is used as the not-equal-to operator. a. == b. <> c. <= d. !=
answer
d. !=
question
In Python the __________ symbol is used as the equality operator. a. == b. <> c. <= d. !=
answer
a. ==
question
Which of the following will hide the turtle if it is visible? a. if turtle.isvisible(): turtle.invisible() b. if turtle.isvisible turtle.hideturtle() c. turtle.isvisible(): turtle.hide() d. if turtle.isvisible(): turtle.hideturtle()
answer
d. if turtle.isvisible(): turtle.hideturtle()
question
Which of the following will determine if the turtle's pen is up and will change it to down if that is the case? a. if turtle.isup(): turtle.isdown() b. if turtle.isdown turtle.penup() c. if not(turtle.isdown()): turtle.pendown() d. if not(turtle.penup()) turtle.penup()
answer
c. if not(turtle.isdown()): turtle.pendown()
question
The ___________ statement is used to create a decision structure.
answer
if
question
In flowcharting, the __________ symbol is used to represent a Boolean expression.
answer
diamond
question
A(n) __________ decision structure provides only one alternative path of execution.
answer
single alternative
question
In a decision structure, the action is ___________ executed because it is performed only when a specific condition is true.
answer
conditionally
question
A(n) __________ operator determines whether a specific relationship exists between two values.
answer
relational
question
A(n) __________ statement will execute one block of statements if its condition is true or another block if its condition is false.
answer
if-else
question
Python provides a special version of a decision structure known as the __________ statement, which makes the logic of the nested decision structure simpler to write.
answer
if-elif-else
question
The logical __________ operator reverses the truth of a Boolean expression.
answer
not
question
Boolean variables are commonly used as __________ to indicate whether a specific condition exists.
answer
flags
question
A(n) ___________ expression is made up of two or more Boolean expressions.
answer
compound
question
The turtle.isdown() function returns ___________ if the turtle's pen is down.
answer
True