Python Operators
Python Operators
Operators are used to perform operations on variables and values. These are standard
symbols used for the purpose of logical and arithmetic operations. Python divides the
operators in the following groups:
Arithmetic operators
Assignment operators
Comparison operators
Logical operators
Identity operators
Membership operators
Bitwise operators
Arithmetic Operators
Arithmetic operators are used to performing mathematical operations like addition,
subtraction, multiplication, and division.
Comparison Operators
Comparison operators are used to compare two values.
Identity Operators
Identity operators are used to compare the objects, not if they are equal, but if they are
actually the same object, with the same memory location.
Membership Operators
Membership operators are used to test if a sequence is presented in an object.
Example,
a, b = 10, 20
# Copy value of a in min if a < b else copy b
min = a if a < b else b
print(min)
The following table lists all operators from highest precedence to lowest.