This and That (or This, But Not That!)


#1

what's my mistake/s?


#2

The key here is to understand the order in which the Python interpreter evaluates "not", "and", "or". These logical operators have a precedence defining the order in which they are evaluated, similar to the way in which mathematical operators such as "*", "+", etc. are evaluated in a certain order. In the case of logical operators, first "not" is evaluated, then "and", then "or" on their respective neighboring arguments. Using parentheses "()" can change this ordering or make it more explicit.

The console indicates that you got bool_two incorrect, so let's examine it.

bool_two = False and not True or True

Using the rules discussed above, we can use parentheses to highlight this precedence and simplify. The following expressions are all equivalent:

bool_two = False and not True or True
= False and (not True) or True
= (False and (not True)) or True
= (False and False) or True
= False or True
= True


#3

Cool Breakdown! Very logical.


#4

Thanks for the breakdown.