Coding
Comparisons and booleans
Compare values and combine the results with and / or / not.
Starting Python…
Comparison operators give you back a boolean — True or False:
| operator | means |
|---|---|
== |
equal to |
!= |
not equal to |
< > |
less / greater than |
<= >= |
less / greater than or equal to |
print(5 > 3) # True
print(5 == 3) # FalseWatch the difference between = and ==. One assigns a value, the other asks a
question. Mixing them up is the single most common beginner bug.
You can combine booleans with and (both must be true), or (at least one), and not
(flips it).
Your task
Using score and attendance, create:
passed— isscoreat least 60?perfect_attendance— isattendanceexactly 100?gets_award— did they pass and have perfect attendance?
You’re done when all 5 checks pass.
Ctrl + Enter runs
The solution unlocks after a few minutes.
Tests
Not run yet- passed is Truenot run yet
- perfect_attendance is Truenot run yet
- gets_award is Truenot run yet
- Still correct for a failing scorenot run yet
- Still correct for patchy attendancenot run yet