Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Operator <=

Tests whether the left operand is less than or equal to the right.

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

Syntax

left <= right

Tests whether the left operand is less than or equal to the right.

Use an inclusive upper bound in a numeric validation rule. Either the left comparison method or its reflected counterpart on the right can establish the result.

For sets the comparison checks membership inclusion instead of size. Two sets with equal size can each fail to be a subset of the other.

For sets the operator tests inclusion and accepts equal sets.

Syntax

left <= right

__le__, __ge__ · TypeError

Worked example

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

Examples

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

Result

True
True

For sets the operator tests inclusion and accepts equal sets.

Sources