Boolean Logic Relating to Python
00:00 In the last lesson, we took a little bit of a look at Boolean logic. In this lesson, we’re going to see how Python uses Boolean logic.
00:10
Here’s some terminology relevant to Boolean logic in Python. Boolean is a type of value that can be either True or False. We signify that using the keyword bool for that type, and it’s a subtype of the int (integer) type. There are two Boolean values, True or False, and in Python those are capitalized.
00:30
A Boolean variable is a variable that can have a Boolean value—specifically, either True or False. We usually use Boolean variables to indicate if a specific condition is present at a particular time within the running of our program.
00:46
A Boolean expression is an expression that returns either True or False. It does a computation and returns True if the result of that computation is True or False if that computation was False.
01:03
A Boolean context is a place where a Boolean expression is expected, such as in an if condition or a while condition. They determine which branch of a selection statement we go into or whether we perform an additional iteration of a while loop.
01:22 Operands are individual parts of larger expressions. If you’re adding two numbers, each number is called an operand. The Boolean logic operators of AND and OR both use two operands and the NOT operation uses a single operand.
01:42
And the keywords that we use for these Boolean operators are and, or, and not.
Become a Member to join the conversation.
