Last time, we learned about Booleans (True
and False
) and how the ==
operator checks if two values are equal, resulting in a Boolean.
Comparisons are essential for making decisions in programs.
Engagement Message
What if we want to check if two values are not equal?
Python uses !=
(an exclamation mark followed by an equals sign) to check for inequality.
10 != 5
evaluates to True
because 10 is not equal to 5.
Engagement Message
What Boolean value would 10 != 10
produce?
We can also compare if one number is greater than another using the >
symbol.
15 > 10
results in True
.
10 > 15
results in False
.
Engagement Message
What do you think 10 > 10
evaluates to?
