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.
Here’s some terminology relevant to Boolean logic in Python. Boolean is a type of value that can be either
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,
False, and in Python those are capitalized.
A Boolean variable is a variable that can have a Boolean value—specifically, either
False. We usually use Boolean variables to indicate if a specific condition is present at a particular time within the running of our program.
A Boolean expression is an expression that returns either
False. It does a computation and returns
True if the result of that computation is
False if that computation was
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
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.
And the keywords that we use for these Boolean operators are
Become a Member to join the conversation.