Python Operators
Operators are used to perform operations on variables and values.
In the example below, we use the operator to add together two values:
+
Example:
print(20 + 10)
Although the + operator is often used to add together two values, like in the example above, it can also be used to add together a variable and a value, or two variables:
Example:
sum1 = 200 + 50 # 250 (200 + 50)
sum2 = sum1 + 250 # 500 (250 + 250)
sum3 = sum2 + sum2 # 1000 (500 + 500)
Types of Operators in Python
Python provides the following types of operators:
- Arithmetic Operators
- Assignment Operators
- Comparison Operators
- Logical Operators
- Identity Operators
- Membership Operators
- Bitwise Operators