Comparison Operators¶
2 == 2
2 == 1
'hello == 'bye'
'Bye' == 'bye'
'2' == 2
2.0 == 2
3 != 3
4 != 5
2 > 1
1 < 2
1 < 2
2 < 5
2 >= 2
4 <= 1
Chaining Comparison Operators with Logical Operators¶
We can use logical operators to combine comparisons:
and
or
not
1 < 2 and 2 < 3
'h' == 'h' and 2 == 2
1 == 1 or 2 == 2
not(1 == 1)