Computer Science, asked by ganeshcm304, 5 months ago

Write a python program to input 2 intergers and one operator and do four function

calculator as per your choice.(+,-,*,/)(as menu driven program)​

Answers

Answered by atrs7391
0

op = int(input("1 for addition, 2 for substraction, 3 for multiplication, 4 for division: "))

n1 = int(input("Enter 1st number: "))

n2 = int(input("Enter 2nd number: "))

def summ():

   a = n1+n2

   print("The result: ", a)

def sub():

   s = n1-n2

   print("The result: ", s)

def mul():

   m = n1*n2

   print("The result: ", m)

def div():

   d = n1/n2

   print("The result: ", d)

if op == 1:

   summ()

elif op == 2:

   sub()

elif op == 3:

   mul()

elif op == 4:

   div()

else:

   print("Cannot solve, wrong operator!")

Similar questions