write a program to implement a simple calculator for two input number . offers choice through a menu in python
Answers
Answered by
3
Explanation:
A simple calculator for two input number . offers choice through a menu in python.
Answered by
2
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)
n1 = int(input("Enter 1st number: "))
op = int(input("1 for addition, 2 for subtraction, 3 for multiplication, 4 for division: "))
n2 = int(input("Enter 2nd number: "))
if op == 1:
summ()
elif op == 2:
sub()
elif op == 3:
mul()
elif op == 4:
div()
else:
print("Cannot solve, wrong operator!")
Similar questions