def su(a,b):

c=a+b

print 'Added value is:',c

def subt(a,b):

if a>b:

c=a-b

print 'Subtracted value is:',c

else:

c=b-a

print 'Subtracted value is:',c

def mul(a,b):

c=a*b

print 'Multiplication value is:',c

def div(a,b):

if b==0:

print 'Division by zero not defined'

else:

c=float(a)/b

print 'Divison value is:',c

def exp(a,b):

c=a**b

print 'Exponent value is:',c

a=int(raw_input('Enter the value of a:'))

b=int(raw_input('Enter the value of b:'))

print ' 1. add 2.sub 3.mul 4. div 5.exp'

n=int(raw_input('Enter the choice:'))

if n==1:

su(a,b) # Function call

elif n==2:

subt(a,b) # Function call

elif n==3:

mul(a,b) # Function call

elif n==4:

div(a,b) # Function call

elif n==5:

exp(a,b) # Function call

else:

print 'Invalid options'

## 1 comment:

You are totally right. This post actually made my day. You can not imagine just how much time I

had spent for this info! Thanks!

Post a Comment