#write a program to add two numbers and return the result.
def karthik_add_fun(a,b):
return(a+b)
def karthik_sub_fun(a,b):
return(a-b)
def karthik_mul_fun(a,b):
return(a*b)
def karthik_div_fun(a,b):
return(a/b)
#read the dataa=int(input("enter vlaue of a: "))
b=int(input("enter value of b: "))
opr=input("enter the desired opr")
if (opr=='+'):
result = karthik_add_fun(a,b)
print("result of adding {} and {} is {}".format(a,b,result))
elif (opr=='-'):
result = karthik_sub_fun(a,b)
print("result of subtracting {} and {} is {}".format(a,b,result))
elif (opr=='*'):
result = karthik_mul_fun(a,b)
print("result of multiplying{} and {} is {}".format(a,b,result))
elif (opr=='/'):
result = karthik_div_fun(a,b)
print("result of dividing {} and {} is {}".format(a,b,result))
else:
print("thanks...")
***************result*************
C:\Users\Radhikasarma\PycharmProjects\untitled\venv\Scripts\python.exe C:/Users/Radhikasarma/PycharmProjects/untitled/karthikproject.py
enter vlaue of a: 50
enter value of b: 50
enter the desired opr/
result of dividing 50 and 50 is 1.0
Process finished with exit code 0
Comments
Post a Comment