Skip to content
    Hack The FutureHack The FuturePython Notes

    UNIT 02 · TOPIC 03

    Comparison / Relational Operators

    Comparison operators compare values and produce a boolean result: ==, !=, <, >, <= and >=.

    The idea

    Comparison / Relational Operators, simply explained

    Comparison operators compare values and produce a boolean result: ==, !=, <, >, <= and >=.

    01

    See the big picture

    How the idea flows

    Input or goalComparison / Relati…Python result
    Understand the problemApply Comparison / Relational Operato…Run the codeCheck the output

    Read the diagram as a simple path: begin with a problem, use the Python idea, then verify the result.

    02

    Everyday connection

    Real-life example

    ↗

    A ticket gate checks whether a rider's age meets the minimum age.

    03

    Learn by doing

    Python code example

    PYTHONExample
    age = 16
    print(age >= 18)
    Expected resultFalse
    Try it: Change one value in the code, predict what will happen, then run it and compare your answer.
    04

    Keep this in mind

    Key takeaways

    • Comparison operators compare values and produce a boolean result: ==, !=, <, >, <= and >=.
    • Think of a real problem where comparison / relational operators could save time or organize information.
    • Test small changes and read the result carefully before moving to a bigger program.

    Quick self-check

    Can you explain it in your own words?

    What is the main idea of Comparison / Relational Operators?

    Comparison operators compare values and produce a boolean result: ==, !=, <, >, <= and >=.

    Where could you see this idea in everyday life?

    A ticket gate checks whether a rider's age meets the minimum age.

    Keep learning · Hack The Future