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
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
Math,
2 months ago
Political Science,
2 months ago
Computer Science,
2 months ago
English,
5 months ago
Math,
5 months ago
Chemistry,
11 months ago
Math,
11 months ago
Math,
11 months ago