Skip to content
UPEEC

Operators

Symbols that combine values: arithmetic, comparison, logical, bitwise, assignment, membership and identity.

Beginner
Comments 0

Operators follow a precedence order (e.g. * before +, not before and before or). When in doubt, use parentheses.

Sub-topics (7)

Arithmetic Operators

+ - * / // % ** — including true division, floor division, modulo and power.

Beginner♥ 0🔖 0💬 0

Comparison Operators

== != < > <= >= compare values and return True or False; they can be chained.

Beginner♥ 0🔖 0💬 0

Logical Operators

and, or, not — with short-circuit evaluation that returns one of the operands.

Beginner♥ 0🔖 0💬 0

Assignment Operators

= plus augmented forms like += -= *= /= //= %= **= &= |= and the walrus :=.

Beginner♥ 0🔖 0💬 0

Membership Operators

in and not in test whether a value is contained in a sequence, set or dict.

Beginner♥ 0🔖 0💬 0

Identity Operators

is and is not check whether two names refer to the very same object.

Easy♥ 0🔖 0💬 0

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.