Check your understanding of the previous reading: comparison operators, boolean operators, and how logic expressions evaluate.
3 < 53 is less than 5.FalseFalse literal is already False.10 == 10.0int and float by value, and 10 equals 10.0.10 == "10"int and a str are never equal in Python, but comparing them with == is not an error: it just evaluates to False.5 == 5.55 and 5.5 are different values.7 != 77 does equal 7, so != is False.3 < "5"int and a str for equality with ==, but ordering comparisons like < between an int and a str are not supported and raise a TypeError. Note: this goes beyond what the reading covered: it only showed ==/!= across types, not ordering comparisons like <.not FalseFalse is True.1 < 2 and 5 < 7True, so and gives True.5 < 4 or 3 == 3False, but the second is True, so or gives True.True or (True and False)True and False is False, but True or False is True.not True and Falsenot applies to True first, giving False; then False and False is False.<< take a left and a right value.notnot only negates a single value.andand combines a left and a right boolean expression.!===, != compares two values.Given the following code:
age = 0
are these two expressions equivalent?
age == 10 or 0
age == 10 or age == 0
Are the two expressions above equivalent?
Select one answer, then check.
age is 0, age == 10 is False, so age == 10 or 0 evaluates to 0 (the unevaluated second operand of or), not a boolean. Meanwhile age == 10 or age == 0 evaluates the second comparison explicitly and gives True. This mirrors the reading's own "Logic Expressions Are Not Distributive" section: you cannot distribute a comparison across an or/and the way you can with arithmetic. or 0 does not become or age == 0 for free.age is 0, age == 10 is False, so the first expression is False or 0, which evaluates to 0, not True/False as a comparison. The second expression evaluates age == 0 explicitly, giving True. The two produce different values, so they are not equivalent. See the reading's "Logic Expressions Are Not Distributive" section.