AI engineering glossary · Python core

What is comparison operator?

Comparison operator (also called relational operator): An operator that compares two values and returns a boolean: == equal, != not equal, <, >, <= and >=. Python allows chaining, so a < b < c checks both comparisons at once. Comparing floats with == is risky because of rounding.

Level: beginnerTopic: Python core

Comparison operator: an example

score >= 40 returns True for 55. The chained test 0 <= x <= 100 checks that x lies between 0 and 100.

Related terms

More Python core terms

Where you learn it

Comparison operator is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.