Comparison Operators

A comparison operator compares two values and produces a Boolean: either True or False. Python has six of them.

Comparison operators
A comparison operator compares two values and produces a Boolean: either True or False. Python has six of them.
OperationDescription
a == ba equal to b
a != ba not equal to b
a < ba less than b
a > ba greater than b
a <= ba less than or equal to b
a >= ba greater than or equal to b
The parentheses around a comparison are not required, but they make it obvious that the whole comparison is one value being stored in the variable.