Python operator

What is operator?

Operator is nothing but symbols that perform certain task.


Various set of operators in python:-

1)Arithmetic Operator

a=50

b=5

print(a+b)

print(a-b)

print(a*b)

print(a/b)

print(a//b)

print(a**b)


2)Relational Operator

a=50

b=5

print(a<b)

print(a>b)

print(a<=b)

print(a>=b)

print(a==b)

print(a!=b)


3)Logical Operator

a=50

b=5

print(a<b and a>b)

print(a>b or a<b)

print(not(a<b and a>b))


4)Bitwise Operator(applicable for int and bool value only)

a=5

b=6

print(a&b)

print(a|b)

print(a^b)

print(~b)

print(a>>1)

print(1<<b)


5)Assignment  Operator

a=111

print(a)


6)Special Operator

 Identity operator (is , is not)

 Membership operator (in , not in) 

Comments