Create a python program to add, subtract, multiply and divide any numbers, using functions with parameters.
Answers
Answered by
3
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
English,
5 months ago
Hindi,
5 months ago
Computer Science,
5 months ago
Geography,
10 months ago
Computer Science,
10 months ago