Quiz 3, Ch 3, Python CS 119

¡Supera tus tareas y exámenes ahora con Quizwiz!

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

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 FalseThird: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 (-)FalseFourth: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.

What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 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 TrueThe whole statement is False because it uses the AND condition not the OR condition.

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

True

Nested decision statements are one way to test more than one condition

True

What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 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 TrueThe whole statement is True because it uses the OR operator not the AND condition.

When using the ________ logical operator, both subexpressions must be true for the compound expression to be true

and

Boolean variables are commonly used as ________ to indicate whether a specific condition exists

flags

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

if-elif-else

Which logical operators perform short-circuit evaluation?

or, and

A(n) ________ decision structure provides only one alternative path of execution

single execution


Conjuntos de estudio relacionados

Georgia Real Estate - Section 14 Unit 3

View Set

Chapter 62 Classification of drugs

View Set

EXAMEN CHAPTER 10 AND 11, Examen capitulo 10 y 11, Chapter 10 y 11, Chapter 10 and 11, Chapter 10 and 11, Chapter 10 and 11, Chapter 10 y 11, Chapter 10 y 11, Chapter 10 and 11, Chapter 10 and 11

View Set

SEMIOLOGIA SISTEMULUI LIMFORETICULAR ȘI A SERIEI ALBE

View Set

HR chapter 11 Incentives and Rewards

View Set

To kill a mocking bird chapter 22-31

View Set

Financial Accounting Pre-Final Quizzes

View Set