Working With Boolean Logic
Since computers work in binary, two values—although we call them one and zero—Boolean algebra became the natural way to design and build computers. Booleanvexpressions are the types of expressions we use in
The use of Boolean operators can allow you more precise and sometimes more complicated conditions to describe which branch of an
if statement to execute or when to repeat an iteration in a
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.
A Boolean expression is an expression that returns either
False. It does a computation and returns
True if the result of that computation is true, and
False if that computation was false. The three Boolean operators are
and, which connects two expressions,
or, which also connects two expressions, and
not, which only acts on a single expression. In Python, the keywords that we use for these operators are, in fact,
Become a Member to join the conversation.