COSC 1336 - Chapter 3 Quiz

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

When using the ________ operator, both sub-expressions must be true for the compound expression to be true.

and

Multiple Boolean expressions can be combined by using a logical operator to create ________ expressions.

compound

A Boolean variable can reference one of two values: ________.

true or false

Short-circuit evaluation is performed with the not operator.

False Why: ...

An action in a single alternative decision structure is performed only when the condition is true.

True

In Python, the ________ symbol is used as the not-equal-to operator.

!=

Decision structures are also known as selection structures.

True

Which logical operators perform short-circuit evaluation?

or, and

What does the following expression mean? x <= y

x is less than or equal to y

In Python the ________ symbol is used as the equality operator.

==

The if statement causes one or more statements to execute only when a Boolean expression is true.

True

Which of the following is the correct if clause to use to determine whether choice is other than 10?

if choice != 10:

Python allows you to compare strings, but it is not case sensitive.

False Why: ...

Python uses the same symbols for the assignment operator and the equality operator.

False Why: ...

Expressions that are tested by the if statement are called Boolean expressions.

True

Nested decision structures are one way to test more than one condition.

True

The Python language is not sensitive to block structuring of code.

False Why: ...

The not operator is a unary operator and it must be a compound expression.

False Why: ...

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

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.

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

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.

A(n) ________ structure is a logical design that controls the order in which a set of statements execute.

control

The decision structure that has two possible paths of execution is known as ________.

dual alternative

Which of the following is the correct if clause to determine whether y is in the range 10 through 50?

if y > 10 and y < 50

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

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.

When using the ________ operator, one or both subexpressions must be true for the compound expression to be true.

Or


Kaugnay na mga set ng pag-aaral

EKG, Sinus Rhythms & Heart Block

View Set

Ch. 4-6 Electronic Health Record SimChart

View Set

Principles of Income Taxation Final Study Guide

View Set

Chapter 21- Managed patient care

View Set

Internal med quiz questions Final

View Set

Introduction to Psychology: Chapters 15-16

View Set

IB Chem: Topic 4.3 Practice Questions

View Set