Operators Overview
Operators are the symbols Python uses to perform work on values — adding numbers, comparing two variables, combining boolean conditions, or checking whether an item belongs to a collection. Every expression you write, from x + 1 to price >= 100 and in_stock, is built out of operators applied to operands (the values on either side).
Python groups its operators into a handful of families, each with its own rules for precedence, associativity, and the types it works on. Rather than cram every operator into one giant page, this section splits them into focused deep-dive pages so each family gets the depth it deserves — worked examples, edge cases, and the gotchas that trip up beginners (and sometimes experienced developers coming from other languages).
The seven operator families
The table below is a quick reference for every category. Treat it as a map: skim it now to see the shape of the territory, then visit each dedicated page for the full explanation.
Category | Operators | Example | Result |
|---|---|---|---|
Arithmetic |
|
|
|
Comparison |
|
|
|
Logical |
|
|
|
Assignment |
|
|
|
Bitwise |
|
|
|
Identity |
|
|
|
Membership |
|
|
|
How to use this section
Arithmetic operators are covered on their own page, including the difference between true division and floor division and the surprising way Python's % handles negative numbers. Comparison operators get a dedicated page that explains chained comparisons like 1 < x < 10, one of Python's more distinctive syntactic features, along with the rules for comparing strings and mixed types.
Logical operators — and, or, and not — have their own page focused on short-circuit evaluation and the common mistake of reaching for the bitwise operators & | ~ when you actually want boolean logic. Assignment operators, including the augmented forms like += and //=, get a full treatment of their own, as do the bitwise operators for anyone working with binary flags, masks, or low-level data.
Identity and membership operators — is versus ==, and in for checking collection contents — are subtle enough to deserve their own page, especially the distinction between "these two variables point to the same object" and "these two variables hold equal values." Finally, the operator precedence page ties everything together with the full precedence table, so you know exactly how an expression like 2 + 3 * 4 ** 2 > 10 and not False gets evaluated.