Comparison Operators
Understanding equality, inequality, and relational operators
Comparison Operators
Comparison operators allow you to compare two values. The result of any comparison is always a boolean — either True or False. You will use these operators constantly when making decisions in your programs.
The Operators
| Operator | Meaning | Example | Result |
|---|---|---|---|
== | equal to | 5 == 5 | True |
!= | not equal to | 5 != 3 | True |
> | greater than | 7 > 3 | True |
< | less than | 2 < 1 | False |
>= | greater than or equal to |