# Python Operators

**Operators in Python Language**

Operators are used to perform Arithmetic, Comparison, and Logical Operations…

**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) =

——————————–

Examples:

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

——————————–

**2) Python Comparison (Relational) Operators**

i) ==

ii) !=

iii) >

iv) <

v) >=

vi) <=

——————-

Examples:

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

ii) += Add And

iii) -= Subtract And

iv) *= Multiply And

v) /= Divide And

vi) %= Modula And

vii) **= Exponent And

viii) //= Floor Division And

Examples:

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) Python Identity Operators**

i) is

ii) is not

Examples:

x1 = 5;

y1 = 5;

print (x1 is not y1); # false

print (x1 is y1); # true

——————————–

**Python Step by Step Tutorial**

**1) In Which sequence should We learn Python?**

**4) Variables and Data Types in Python**

**6) Python Conditional Statements**

**9) Python Lists**

——————————