Values can be compared for equality using the operator ==
:
3 == 3
3 == 4
The special symbols True
and False
are used to denote truth values. Naturally, there are inequality comparisons as well:
3 > 4
Inequalities can be chained:
3 < 4 >= 2 != 1
Truth values can be negated using !
(logical not) and combined using &&
(logical and) and ||
(logical or):
!True
!False
3 < 4 && 6 > 5
&&
has higher precedence than ||
, i.e. it binds stronger:
True && True || False && False
True && (True || False) && False