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.| Operation | Description |
|---|---|
a == b | a equal to b |
a != b | a not equal to b |
a < b | a less than b |
a > b | a greater than b |
a <= b | a less than or equal to b |
a >= b | a 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.