COSC 1336 - Chapter 3 Quiz

7 September 2022
4.7 (114 reviews)
25 test answers

Unlock all answers in this set

Unlock answers (21)
question
Short-circuit evaluation is performed with the not operator.
answer
False Why: ...
question
Multiple Boolean expressions can be combined by using a logical operator to create ________ expressions.
answer
compound
question
The not operator is a unary operator and it must be a compound expression.
answer
False Why: ...
question
Python allows you to compare strings, but it is not case sensitive.
answer
False Why: ...
question
Which of the following is the correct if clause to determine whether y is in the range 10 through 50?
answer
if y > 10 and y < 50
question
Python uses the same symbols for the assignment operator and the equality operator.
answer
False Why: ...
question
The decision structure that has two possible paths of execution is known as ________.
answer
dual alternative
question
The if statement causes one or more statements to execute only when a Boolean expression is true.
answer
True
question
What is the result of the following Boolean expression, if x equals 5, y equals 3, and z equals 8? x < y and z > x
answer
False Why: ... If (x=5) < (y=3), this is False. AND = the condition, both must be true. (z=8) > (x=5), this is True The whole statement is False because it uses the AND condition not the OR condition.
question
What is the result of the following Boolean expression, if x equals 5, y equals 3, and z equals 8? not ( x < y or z > x ) and y < z
answer
False Why: ... First: NOT = operator #1, this means the value of this expression must be reversed. so... Second: [ (x=5) < (y=3), expression 1 is False Third: OR = the operator #2, one of these must be true. (z=8) > (x=5) ], expression 2 is True - so far the sub-expression 1, in brackets, is True. ---> Now: you must reverse the value per first step. true value is now (-)False Fourth: AND= operator #3, both (sub-expression 1 and sub-expression 2 ) must be true. (y=3) < (z=8), sub-expression 2 is True. ---> This means that expressions 2-4, or sub-expression1 and sub-expression 2, as a whole is (+)True. Finally: Remember two (-)negatives make a (+)positive. This contains one neg., First step and one pos., expression 2-4 as a whole, so this would print that the compound expression is False.
question
What is the result of the following Boolean expression, if x equals 5, y equals 3, and z equals 8? x < y or z > x
answer
True Why: ... If (x=5) < (y=3), this is False. OR = the operator , one of these expressions must be true. (z=8) > (x=5), this is True The whole statement is True because it uses the OR operator not the AND condition.
question
Decision structures are also known as selection structures.
answer
True
question
A(n) ________ structure is a logical design that controls the order in which a set of statements execute.
answer
control
question
A Boolean variable can reference one of two values: ________.
answer
true or false
question
In Python, the ________ symbol is used as the not-equal-to operator.
answer
!=
question
When using the ________ operator, both sub-expressions must be true for the compound expression to be true.
answer
and
question
Nested decision structures are one way to test more than one condition.
answer
True
question
When using the ________ operator, one or both subexpressions must be true for the compound expression to be true.
answer
Or
question
An action in a single alternative decision structure is performed only when the condition is true.
answer
True
question
Which logical operators perform short-circuit evaluation?
answer
or, and
question
Expressions that are tested by the if statement are called Boolean expressions.
answer
True
question
The Python language is not sensitive to block structuring of code.
answer
False Why: ...
question
In Python the ________ symbol is used as the equality operator.
answer
==
question
Which of the following is the correct if clause to use to determine whether choice is other than 10?
answer
if choice != 10:
question
What does the following expression mean? x <= y
answer
x is less than or equal to y