Reviewing How the Python or Operator Works
00:00
We’ve spent the last few lessons taking a look at the syntax of using Python’s or operator, and so let’s review what you’ve learned.
00:09
It is a Boolean operator. It returns True if one or both of the two Boolean expressions it operates on is True and it returns False if both are False.
00:22
But because of the way it’s implemented, we can use it on other things. We can use it on objects, where if the first object evaluates to be True, we get the first object and if the first object evaluates to be False, we get the second object.
00:36
And it actually won’t evaluate the second operand unless it needs to. If the first operand proves to be True, there’s no reason to continue the operation because we know the whole thing is going to be True.
00:49
We extend that with the idea of using objects, that if the first object evaluates to True, that’s our result. We don’t need to look at the second operand unless the first one is False.
01:02 As a Python programmer, we can take advantage of lazy evaluation, short-circuit evaluation, to make our programs more efficient.
01:12
So now that we know syntactically how to connect two expressions with the word or and what the result of that operation will be, the next few lessons will take a look at where we use or statements within our Python programs.
Become a Member to join the conversation.
