MWZ

MINDWAREZONE

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:

  1. Arithmetic Operators
  2. Assignment Operators
  3. Comparison Operators
  4. Logical Operators
  5. Identity Operators
  6. Membership Operators
  7. Bitwise Operators