**Hey guys! **Welcome to another interesting article. Here, we will discuss Python operators and different types of Python Operators with examples.

## Operators in Python

**Python** operators are special symbols which are used in carrying out arithmetic and logical computation. Operators in python are simply used for performing operations on variables and values. And operands are those values which an operator operates.

## Types of Python Operators

Here, we will learn about the different types of Python Operators. There are seven types of Python Operators which are discussed as follows;

### 1. Arithmetic Operators

Arithmetic Operators are those operators which are used in performing mathematical computations such as addition, multiplication, subtraction, division, etc.

Operator | Discription | Example |
---|---|---|

+ | Addition of two operands | x+y |

- | Substraction of two operands | x-y |

* | Multiplication of two operands | x*y |

/ | Division of one operand by other | x/y |

% | Modulus- remainder when one operand is divided by other | x%y |

// | Floor Division- Divides one operand by other and results into whole number that is adjusted to the left in number line | x//y |

** | Exponent- Operand one raised to power of second | x**y |

**Arithmetic Operators Example: **Here we will take a simple example of **Substraction** where we will Subtract two digits ie.,

x = 10y = 7

print(x - y)

**Output**

3

### 2. Comparison Operators

Comparison Operators are those operators which are used for comparing values. And according to condition, it returns either True or False.

Operator | Discription | Example |
---|---|---|

< | Less than: True if the operand in left is less than the operand in right | x<y |

> | Greater than: True if the operand in left is greater than the operand in right | x>y |

== | Equal to: True if both left and right operands are equal | x==y |

!= | Not equal to: True if both operands are not equal | x!=y |

<= | Less than or equal to: True if the operand in left is less than or equal to the operand in right | x<=y |

>= | Greater than or equal to: True if the operand in left is greater than or equal to the operand in right | x>=y |

**Comparison Operators Example:**Here we will take a simple example of

**less than**operator where we will compare two digits and know whether it is true or false;

x = 10y = 6

print(x < y)

**Output**

False

### 3. Logical Operators

Logical Operators are those operators which are used for combining conditional statements such as Or, And, Not operators.

Operator | Discription | Examples |
---|---|---|

and | True if both first & second operands are true | x and y |

or | True if either first or second operands is true | x or y |

not | True if one of the operands is false | not x |

**Logical Operators Example:**Here we will take a simple example of

**and**Operator;

x = 7

print(x > 3 and x < 10)

**Output**

True

### 4. Bitwise Operators

Bitwise Operators are those operators which operates bit by bit and are used for operating binary numbers.

Operator | Discription | Example |
---|---|---|

& | Bitwise AND | x&y |

| | Bitwise OR | x|y |

~ | Bitwise NOT | ~x |

^ | Bitwise XOR | x^y |

>> | Bitwise right shift | x>> |

<< | Bitwise left shift | x<< |

**Bitwise Operators Example:**Here we will take a simple example of

**Bitwise OR**operator;

a = 20b = 8

print("a | b =", a | b)

**Output**

a | b = 28

### 5. Identity Operators

Identity operators are those operators that are used to check whether the two values are located in the memory at same part or not. [is not] and [is] are both identity operators.

Operator | Discription | Examples |
---|---|---|

is | True if both operands are identical | x is True |

is not | True if both operands are not identical | x is not True |

**Identity Operators Example:**Here we will take a simple example of

**is**Operator;

x = ["john", "Daniel"]y = ["john", "Daniel"]

z = x

print(x is z)

print(x is y)

print(x == y)

**Output**

TrueFalse

True

### 6. Membership Operators

Membership Operators are those operators that are used in testing that whether a variable or value is in sequence or not. [not in] and [in] are both membership operators.

Operator | Discription | Examples |
---|---|---|

in | True if the value is in sequence | 5 in x |

not in | True if value is not in sequence | 5 not in x |

**Membership Operators Example:**Here we will take a simple example of

**in**Operator;

x = ["Mango", "banana"]

print("banana" in x)

**Output**

True

### 7. Assignment Operators

Assignment Operators are those operators which are used in assigning values to the variables.

Operator | Discription | Examples |
---|---|---|

= | Assign value of right side expression to left side operand | x=y+z |

+= | Add AND- It adds the operand of right side with left side and then assign to the left side operand | x+=y x=x+y |

-= | Subtract AND- Subtract the operand of right side from left side and then assign to the left side operand | x-=y x=x-y |

*= | Multiply AND- Multiplies the operand of right side with the left side operand and then assign to the left side operand | x*=y x=x*y |

/= | Divide AND- Divide the operand of left side with the right side operand and then assign to the left side operand | x/=y x=x/y |

**= | Exponent AND- Calculate the exponent value and then assign to the left side operand | x**=y x=x**y |

//= | Divide (Floor) AND- Divide the operand of left side with the right side operand and then assign to the value to the left side operand | x//=y x=x//y |

%= | Modulus AND- First take the modulus using the operand of left and right side and then assign the value to the left side operand | x%=y x=x%y |

**Assignment Operators Example:**Here we will take a simple example of

**add AND**Operator;

x = 5x += 3

print(x)

**Output**

8

## Conclusion

Above we have discussed the Python operators and different types of Python Operators with examples. Python operators are special symbols which are used in carrying out arithmetic and logical computation. Operators in python are simply used for performing operations on variables and values. I hope this information is helpful to you all.