Skip to main content

Chapter 4a - Boolean

A boolean is True or False. Compare numbers with ==, !=, >, <, >=, <=.

OperatorMeaning
==Equal
!=Not equal
>Greater
<Less
πŸ§ͺ Try it

Mini quiz β€” comparisons​

Quiz

Comparisons

1 / 2

What 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​

Quiz

Boolean

1 / 2

What 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.