# Python Operators

Python Operators, Arithmetic Operators, Comparison (Relational) Operators, Assignment Operators, Logical Operators, and Bitwise Operators.

## Operators in Python Language

• Operators are used to perform Arithmetic, Comparion, Assignment, and Logical Operations.
• Operators are used to perform operations on variables and values

Example:

a=10
b=20
c=a*b
d=12+34

print(c) #200
print(d) # 46
print(100/4) # 25.0
print(a+b*7) # 150

Important categories of operators in Python:

1. Arithmetic Operators
2. Comparison (Relational) Operators
3. Assignment Operators
4. Logical Operators
5. Identity Operators
6. Bitwise Operators

#### 1. Python Arithmetic Operators

i) + Addition (Example: 10 + 20) = 30
ii) – Subtraction (Example: 10 – 20) = -10
iii) * Multiplication (Example: 10 * 20) = 200
iv) / Division (Example: 20/10) = 2
v) % Modulus (Example: 20 % 10) = 0
vi) ** Exponent (Example: 10 ** 20) =

Example:

a=10
b=20
c=3

print (a+b)
print (a-b)
print (a*b)
print (a/c)
print (b%a)
print (a**c)
print (a//c)

Output:
30
-10
200
3.3333333333333335
0
1000
3

i) ==
ii) !=
iii) >
iv) <
v) >=
vi) <=
——————-
Example:
a=10
b=20

print (a == b)
print (a != b)
print (a > b)
print (a < b)
print (a >= b)
print (a <= b)

Output:
False
True
False
True
False
True

#### 3. Python Assignment Operators

i) = Equal to
iii) -= Subtract And
iv) *= Multiply And
v) /= Divide And
vi) %= Modula And
vii) **= Exponent And
viii) //= Floor Division And

Example:

a=10
b=3
print (a)
print (b)

a += b
print (a)

a -=b
print (a)

a *=b
print (a)

a /=b
print (a)

a **=b
print (a)

a //=b
print (a)

Output:
10
3
13
10
30
10.0
1000.0
333.0

#### 4. Python Logical Operators

i) and (Loical And)
ii) or (Loical Or)
iii) Not (Loical Not)

Examples:
x=’true’
y=’false’

print (x and y) # false

print (x or y) # true

print (not x) # false

#### 5. Identity Operators

i) is
ii) is not

Examples:

x1 = 5
y1 = 5

print (x1 is not y1) # false

print (x1 is y1) # true