0% found this document useful (0 votes)
34 views3 pages

New 3

The document discusses the important categories of operators in Python including arithmetic, comparison, assignment, logical and identity operators providing examples of each.

Uploaded by

Raj Pradeep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views3 pages

New 3

The document discusses the important categories of operators in Python including arithmetic, comparison, assignment, logical and identity operators providing examples of each.

Uploaded by

Raj Pradeep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

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

You might also like