Chapter 4a - Boolean
A boolean is True or False. Compare numbers with ==, !=, >, <, >=, <=.
| Operator | Meaning |
|---|---|
== | Equal |
!= | Not equal |
> | Greater |
< | Less |
π§ͺ Try it
Mini quiz β comparisonsβ
Comparisons
1 / 2What is this?
2 == 2
Pick an answer to see if you are right.
Challenge: is olderβ
Write is_older(a, b) so it returns True if a is strictly greater than b.
Logical operatorsβ
and needs both sides true. or needs at least one true. not flips the value.
π§ͺ Try it
Mini quiz β booleanβ
Boolean
1 / 2What is this?
5 >= 5
Pick an answer to see if you are right.
Exercisesβ
Activity: Same age
Write same_age(a, b) so it returns True when the two ages are equal.