Appendix D: Python operators
This appendix lists the Python operators you are likely to need, organised by category.
D.1. Arithmetic operators
| Precedence | Operator | Name | Description |
|---|---|---|---|
Highest |
|
Unary minus |
Negation |
High |
|
Multiplication |
Multiply values |
|
True division |
Floating-point division |
|
|
Floor division |
Integer division (floor) |
|
|
Modulo |
Remainder |
|
Normal |
|
Addition |
Add values |
|
Subtraction |
Subtract value |
D.2. Boolean operators
| Precedence | Operator | Name | Description |
|---|---|---|---|
Highest |
|
Logical NOT |
Inverts truth value |
High |
|
Logical AND |
True if both operands are true |
Normal |
|
Logical OR |
True if either operand is true |
D.3. Comparison operators
| Precedence | Operator | Name | Description |
|---|---|---|---|
Normal |
|
Ordering |
Relational comparisons |
|
Equality |
Value comparison |
|
|
Identity |
Object identity test |
|
|
Membership |
Membership test |
D.4. More operators
In this appendix we have omitted some advanced operators. There is a full list of operators in the Python documentation.