An operator performs an operation on one or more operands. Python applies operators to built-in values and user-defined objects when the relevant special methods are available. section 3.1
Common operator families include:
- Arithmetic operators such as +, -, *, /, //, and % combine or transform numeric values. Python 3 division with / produces a floating-point result; // performs integer division. section 4.12 section 4.5
- Comparison operators include <, <=, >, >=, ==, and !=. Membership uses in and not in, while identity uses is and is not. section 8.11.2
- Boolean operators and, or, and not combine Boolean expressions. Evaluation short-circuits, and and or return operand objects rather than necessarily Boolean values. section 8.11.2
- Parentheses clarify grouping when precedence could make an expression difficult to read or interpret. section 8.11.2 section 4.5
Arithmetic expression
x = 3 y = 5 z = (x + y) / 2 Here, parentheses force addition before division, and z receives the average as a floating-point result. section 4.5
Path construction with /
from pathlib import Path cur_path = Path() path = cur_path / 'bin' / 'utils' / 'disktools' The slash operator combines Path operands into a pathname and adapts its representation to the operating system. section 12.2.5
if 0 < x < 10: ...
Compare chained comparison syntax with a longer expression for testing whether x lies within a range. section 8.11.2






