Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Getting Started With Python's and Operator

00:00 In this lesson, you’ll see the basic definition of the and operator.

00:06 As the word suggests, an operator acts on one or more items, which are called operands. For example, if you add two numbers together, those two numbers are called the operands.

00:19 For and, the operands can be two Boolean expressions, two other types of objects—which you’ll see in future lessons—or even a combination of both.

00:32 Since it takes two operands, and is referred to as a binary operator.

00:39 This table, called a truth table, shows the behavior of the and operator. Basically, if both operands evaluate to True, then the and of those expressions is True. In all other cases, the result of the and operation is False. So if you’re taking the and of two expressions, exp1 and exp2, if both are False, the and of them is False.

01:09 If the first one is False and the second one is True, False and True is False. In the next row, True and False is False.

01:24 And finally, in the last row, True and True is True. I want you to make an observation about this table. Notice that if expression one is False, the and of both expressions is False.

01:41 It’s essentially the first expression, no matter what the second expression is. And in the second two rows, where the first expression is True, then the result of the and operation is whatever the expression two is.

01:56 The Python programming language and the programmers who use it take advantage of this operation when writing programs. And you’ll see that in future lessons as well.

02:08 But in the next lesson, you’ll see the most basic cases of using the and operator in Python.

Become a Member to join the conversation.