#!/usr/bin/python
#filename:test3.py
a = 21
b = 10
c = 0
#part one : assignment operator
c = a + b
print ("Line 1 - Value if c is ",c)
c += a
print ("Line 2 - Value of c is ",c)
c *= a
print ("Line 3 - Value of c is ",c)
c /= a
print ("Line 4 - Value of c is ",c)
c = 2
c %= a
print ("Line 5 - Value of c is ",c)
c **=a
print ("Line 6 - Value of c is ",c)
c //=a
print ("Line 7 -Value of c is",c)
# part two : bit operator
a = 60
b = 13
c = 0
c = a & b
print ("Line 1 - Value of c is ",c)
c = a | b
print ("Line 2 - Value of c is ",c)
c = a ^ b
print ("Line 3 - Value of c is ",c)
c = ~a
print ("Line 4 - Value of c is ",c)
c = a << 2
print ("Line 5 - Value of c is ",c)
c = a >> 2
print (" Line 6 - Value of c is ",c)
#part three : logical operator
a = 10
b = 20
c = 0
if( a and b ):
print ("Line 1 - a and b are true ")
else :
print ("Line 1 - ether a or b is not true ")
if( a or b ):
print ("Line 2 - at least one of them is true ")
else :
print ("Line 2 - Neither a nor b is true")
a = 0
if( a and b ):
print ("Line 3 - a and b are true")
else:
print ("Line 3 - either a or b is not true")
if not( a and b):
print ("Line 5 - either a or b is not true")
else :
print ("Line 5 - a and b are true")
# part four
a = 20
b = 20
if( a is b):
print ("Line 1 - a and b have same identity")
else:
print ("Line 1 - a and b do not have same identity")
if( id(a) == id(b)):
print ("Line 2 - a and b have same identity")
else:
print ("Line 2 - a and b do not have same identity")
b = 30
if( a is b):
print ("Line 4 - a and b do not have same identity")
else:
print ("Line 4 - a and b do not have same identity")
if(a is not b ):
print ("Line 4 - a and b do not have same identity")
else:
print("Line 4 - a and b have the same identity")
#PART FIVE
a = 20
b = 10
c = 15
d = 5
e = 0
e = ( a + b )*c/d
print ("value of (a + b) * c / d is ",e)
e = ((a + b ) * c)/d
print ("value of ((a+b)*c)/d is ",e)
e = ( a + b) * (c / d)
print ("value of ( a + b) * (c/d) is ",e)
e = a + (b * c) /d
print ("Value of a + ( b * c)/d is ",e)
#PART SIX
num = 5
if num == 3:
print ("boss")
elif num == 2:
print ("user")
elif num ==1:
print ("worker")
elif num < 0 :
print ("error")
else:
print ("roadman")
num = 9
if num >= 0 and num <= 10:
print ("hello")
else:
print ("undefine")
if(num >=0 and num <= 5) or (num >= 10 and num <= 15):
print ("hello")
else:
print ("undefine")