Tall enough
You must be at least 120 cm tall to ride.
03OPERATORS · COMPARE
A comparison sign looks at two values and answers True or False. Next, if will use those answers to choose a path.
IN REAL LIFE
At least, at most, more than: you hear these words every day.
You must be at least 120 cm tall to ride.
If it is later than 9, it is time to sleep.
Score 100 or more to unlock level 2.
WORDS INTO SIGNS
| Sign | In words | Example | Answer |
|---|---|---|---|
== | the same as | 5 == 5 | True |
!= | not the same as | 5 != 3 | True |
< | less than | 3 < 2 | False |
> | more than | 3 > 2 | True |
<= | at most | 4 <= 4 | True |
>= | at least | 120 >= 130 | False |
A trick: In <= and >=, the = always goes second. >= works, => does not.
STEP BY STEP
Each comparison gives its own True or False.
height = 125PyBot is 125 cm tall.height >= 120Is 125 at least 120? True. PyBot can ride.height >= 130Is 125 at least 130? False. Not the big ride yet.height == 125Is it exactly 125? True.LOOK FIRST
height = 125 fills a box. height == 125 asks a question.
2 + 3 == 5: Python does the math, then compares. True.
"cat" == "cat" is True, but "Cat" == "cat" is False.
RUN IT
Guess first. Then run real Python and check.
height = 125
print(height >= 120)
print(height < 100)What will Python show?
PyBot's hint
Ready. Press Run Python.
Pyodide 314.0.3 runs CPython in your browser with WebAssembly.
Open-source under the Mozilla Public License 2.0. License
Now change one thing: Change 125 to 120. Is 120 >= 120? Then change >= to >.
YOUR TURN
Try each tiny question. A wrong answer becomes something to review.
Can Mia get the prize?
10 >= 10What does Python answer?
7 <= 5What does Python answer?
3 > 3What does Python answer?
4 != 4What does Python answer?
2 + 2 == 4What does Python answer?
"Cat" == "cat"What does Python answer?
Which line is right?
PyBot wins a prize with 10 points or more. It has exactly 10 points, but it shows False. Change the sign so it shows True.
TrueOUTPUT
Want a fresh start? Clear only this page.
Next: when a line has many signs, which one goes first?