Mixing Boolean Expressions and Objects
In this lesson, you’ll learn that you can actually mix Boolean expressions with objects using
and. And once you understand how Python implements
and, you’ll see that it’s not much different.
y will evaluate to
x is false, and it doesn’t matter if
x is a Boolean expression or an object. Likewise, if
x is true, the result is
y, and it too can be a Boolean expression or an object.
So let’s look at some examples. Here, the first expression is true, so the result will be second expression,
2. Switching them around,
2 is true, so the result will be
2 < 4, which evaluates to
Become a Member to join the conversation.