A Boolean is a data type that represents either True or False.
Example:
is_raining = True
is_sunny = False
Booleans are useful for making decisions in your code — especially when working with conditions and filters.
Comparison operators compare two values and return a Boolean result (True
or False
). Here are the most common:
==
(equal to): 5 == 5
→ True
!=
(not equal to): 4 != 5
→ True
>
(greater than): 10 > 3
→ True
<
(less than): 2 < 8
→ True
>=
(greater than or equal to): 5 >= 5
→ True
<=
(less than or equal to): 4 <= 3
→ False
You can also store comparisons in variables:
is_older = age > 18