Aiphabet
Lesson · 0 of 4 items
Log in
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)    # False

Watch 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 — is score at least 60?
  • perfect_attendance — is attendance exactly 100?
  • gets_award — did they pass and have perfect attendance?
You’re done when all 5 checks pass.
Ctrl + Enter runs

Tests

Not run yet
  • passed is True
    not run yet
  • perfect_attendance is True
    not run yet
  • gets_award is True
    not run yet
  • Still correct for a failing score
    not run yet
  • Still correct for patchy attendance
    not run yet