Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Operator <

Tests strict ascending order between comparable operands.

Version: Python 3.14; repository image, production runtime not attested

Syntax

left < right

Tests strict ascending order between comparable operands.

A strict upper-bound comparison excludes equality, useful for half-open index ranges. Built-in sorting uses this comparison to order items.

Sets use a partial order based on proper inclusion. Disjoint nonempty sets can both fail the less-than comparison in either direction.

For sets this tests proper inclusion, so equal sets fail the test.

Syntax

left < right

__lt__, __gt__ · TypeError

Worked example

{2} < {2} → False
{2} < {2, 3} → True

Examples

print(3 < 7)
print({2} < {2})

Result

True
False

For sets this tests proper inclusion, so equal sets fail the test.

Sources