Previous Topic: Logical OperatorsNext Topic: Operator Precedence


Equality and Comparison Operators

Comparison operators are used with strings and numeric data. Comparison operators evaluate to a Boolean value. They return True or False based on the outcome of the tested condition.

Operator

Description

==

Equal to

===

Identity

!=

Not equal to

!==

Non-identity

<

Less than

<=

Less than or equal to

>

Greater than

>=

Greater than or equal to

?:

Tertiary conditional operator

The expression

x1 ? x2 : x3

returns x2 when x1 is True or x3 when x1 is False.