Python Comparison Operators: >, <, ==, and True/False

True or False — how the dragon tests a value before deciding anything.

  • Lesson 1 of 5
  • PRO
  • Ages 10+
  • 4 hands-on levels
See what PRO unlocksA one-time $49.99 purchase. Topics 1–3 are free.

The dragon explains

Asking questions about numbers

  1. The dragon: Before the dragon can DECIDE anything, it needs to ASK a question. That's what comparisons do.

  2. The dragon: Comparing two things gives you an answer of True or False. Nothing else — just those two words.

    example.pyPython 3
    print(80 > 50)
    OutputTrue
  3. The dragon: Flip the numbers and you might flip the answer.

    example.pyPython 3
    print(30 > 50)
    OutputFalse
  4. The dragon: Careful with 'at least' or 'at most' — the boundary matters. > leaves the exact number OUT.

    example.pyPython 3
    strength = 50print(strength > 50)
    OutputFalse
  5. The dragon: >= means 'greater than OR equal to'. That includes the boundary.

    example.pyPython 3
    strength = 50print(strength >= 50)
    OutputTrue
  6. The dragon: And checking if two things are EQUAL uses two equals signs, not one — one = is for filling a box.

    example.pyPython 3
    gold = 100print(gold == 100)
    OutputTrue

Quick check

Check your understanding

Say your answer out loud before reading the marked one. Every wrong option is a mistake real beginners make.

  1. Question 1 of 2

    health is exactly 20. What does print(health > 20) say?

    question.pyPython 3
    health = 20print(health > 20)
    • FalseCorrect
    • True
    • 20

    Why: 20 is not bigger than 20, so print(health > 20) says False. > is strict — the boundary itself does not count. That's what >= is for.

  2. Question 2 of 2

    gold = 5. What does print(gold = 5) do — with ONE equals sign, inside print?

    question.pyPython 3
    gold = 5print(gold = 5)
    • That's actually an error — = isn't a questionCorrect
    • True
    • 5

    Why: A single = always means assignment, never a question — Python won't let you use it to compare. That's exactly why == exists: two equals signs specifically for asking 'are these the same?'

In the game

What you'll practice

Four levels in the game: one guided first try with the shape of the answer already there, then three to solve on your own.

  1. 1

    GuidedYour first try

    The dragon's strength is 80. Ask Python: is that MORE than 50? print() the answer — Python already knows how to say True or False.

  2. +3

    PracticeThree more, on your own

This lesson is part of PRO.

PRO is a one-time $49.99 purchase, no subscription, and unlocks this whole topic along with everything else. Topics 1–3 are free, start to finish.

Unlock this lesson with PRO

Stuck three times? The game offers the answer — unasked.