There are five groups of operators in the Python programming language: arithmetic, comparison, assignment, logical, identity, membership, and bitwise.
- Arithmetic operators – are used to perform basic mathematical operations
- Comparison operators – are used to compare values, they return a True/False based on the statement
- Assignment operators – are used to perform some operation and assign a value to a variable
- Logical operators – are used to combine conditional statements
- Identity operators – are used to determine if objects are the same
- Membership operators – are used to determine if a value is found in a sequence
- Bitwise operators – are used to perform operations at the bit level
You can combine various operators together:
>>> x = 3
>>> (x < 5 + 1) and (x > 1)
Order of operation
In Python, just like in Math order of arithmetic operations is governed by PEMDAS – Parentheses, Exponent, Multiplication, Division, Addition, Subtraction.
>>> 3 + 2 * 8
>>> (3 + 2) * 8