# What are the operators in the Python Language?

Python Arithmetic Operators are
+  +2, 2+3, 4+8 etc
- -5,5-9, 9-5
* 4*5
/    5/4
// floor division 5//3
** Exponent 2**3
% remainder  6%2
• Bitwise operators
• &   And
• |     Or
• ^    XOR

def tobinary(n):
output=""
while n>0:
r=n % 2
n=n // 2
output= str(r) + output
if output=="":
return "0"
return output
a=4
b=5
c=a | b
d=a & b
e=a ^ b
print("A = {0}, B = {1}, A | B = {2}, A & B = {3}, A ^ B = {4}".format(a,b,c,d,e))
print("A = {0}, B = {1}, A | B = {2}, A & B = {3}, A ^ B = {4}".format(tobinary( a),tobinary(b),tobinary(c),tobinary(d),tobinary(e)))

Assignment Operators
=. a=b, copies value of b into a. b=5, a=b. a becomes 5
a+=b. b=5, a=3, a+=b = a= a+b. a=3+5=8
a%=b equals a=a%b
a**=b equals a=a**b
a/=b equals a=a/b
a*=b equals a=a*b
a-=b equals a=a-b
a//=b equals a=a//b

`a=3b=5a=a+bprint(a)a=3b=5a+=bprint(a)`

Membership operators
1. in
2. not in

`s="1,2,3,4"x="2"print(x in s)print( x not in s)x="45"print(x in s)print( x not in s)`

Identity Operators
1. is
2. is not
Checks if two variables are the same
`a=[1,2,3,4]b=aprint(a,b,a is b)b[2]=88print(a,b,a is b)a=[1,2,3,4]b=list(a)print(a,b,a is b)b[2]=88print(a,b,a is b)`
Relational
a<b, a>b, a<=b, a>=b, a==b, a!=b
`a=1b=1print(a<b,a<=b,a>b,a>=b,a==b,a!=b)print(not a<b, not a<=b,not a>b,not a>=b,not a==b,not a!=b)`

Logical
a and b, a or b, not a
`a=Falseb=Falseprint("{0} or {1}={2}".format(a,b,a or b))a=Falseb=Trueprint("{0} or {1}={2}".format(a,b,a or b))a=Trueb=Falseprint("{0} or {1}={2}".format(a,b,a or b))a=Trueb=Trueprint("{0} or {1}={2}".format(a,b,a or b))a=Falseb=Falseprint("{0} and {1}={2}".format(a,b,a and b))a=Falseb=Trueprint("{0} and {1}={2}".format(a,b,a and b))a=Trueb=Falseprint("{0} and {1}={2}".format(a,b,a and b))a=Trueb=Trueprint("{0} and {1}={2}".format(a,b,a and b))`