Boolean Expressions
Table of contents
Description
A boolean expression is any logical statement that evaluates to either True
or False
. They can be a comparison, an identity or membership test, or methods that return a boolean value.
- Python Docs: Truth Value Testing
Example
Comparison Operators
<
, <=
, >
, >=
, ==
, and !=
are comparison operators. They compare 2 values and return a True
or False
. They can also be “chained” together:
Boolean Operators
and
, or
, and not
are boolean operators. They are used to change or combine the results of a boolean expression:
Boolean Functions and Methods
Methods and functions applied to variables can sometimes return a True
or False
: