Computer Science, asked by zohaphobia, 10 months ago

Create a python program to add, subtract, multiply and divide any numbers, using functions with parameters.

Answers

Answered by atrs7391
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