# [Python Operators] What is the operator in Python? How many types of operators are in Python?

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

## 1. Arithmetic operators

``````+ (addition)
- (subtraction)
*(multiplication)
/(divide), %(reminder)
//(floor division)
exponent (**) operators.``````
``````# Arithmetic Operator
a = 9
b = 4

a1 = a + b

# Subtraction
a2 = a - b

# Multiplication
a3 = a * b

# Division(float)
a4 = a / b

# Division(floor)
a5 = a // b

# Modulo of both number
a6 = a % b

# Power
a7 = a ** b

# print results
print(a1)
print(a2)
print(a3)
print(a4)
print(a5)
print(a6)
print(a7)
``````

Output
13
5
36
2.25
2
1
6561

## 2. Comparison operators

``````# Relational Operators
a = 13
b = 33

# a > b is False
print(a > b)

# a < b is True
print(a < b)

# a == b is False
print(a == b)

# a != b is True
print(a != b)

# a >= b is False
print(a >= b)

# a <= b is True
print(a <= b)
``````

Output
False
True
False
True
False
True

## 3. Assignment Operators

``````# Assignment Operators
a = 10

# Assign value
b = a
print(b)

b += a
print(b)

# Subtract and  value
b -= a
print(b)

# multiply and assign
b *= a
print(b)

# bitwise lishift operator
b <<= a
print(b)
``````

Output
10
20
10
100
102400

## 4. Logical Operators

``````# Logical Operator
a = True
b = False

# Print a and b is False
print(a and b)

# Print a or b is True
print(a or b)

# Print not a is False
print(not a)
``````

Output:
False
True
False

## 5. Bitwise Operators

``````# Bitwise operators
a = 10
b = 4

# AND operation
print(a & b)

# OR operation
print(a | b)

#  NOT operation
print(~a)

#  XOR operation
print(a ^ b)

# right shift operation
print(a >> 2)

# left shift operation
print(a << 2)
``````

Output:
0
14
-11
14
2
40

## 6. Membership Operators

``````
x = 24
y = 20
list = [15, 20, 35, 40, 50]

if (x not in list):
print("x is NOT present in given list")
else:
print("x is present in given list")

if (y in list):
print("y is present in given list")
else:
print("y is NOT present in given list")
``````

Output
x is NOT present in given list
y is present in given list

## 7. Identity Operators

``````a = 10
b = 20
c = a

print(a is not b)
print(a is c)
``````

Output:
True
True

Keywords:

What is the operator in Python?
What are the 3 operators in Python?
What are the 4 operators in Python?
How many types of operators are in Python?
Arithmetic operators,
Comparison operators,
Assignment Operators,
Logical Operators,
Bitwise Operators,
Membership Operators,
Identity Operators,