Programming Examples
Python function to accept 2 number and return addition subtraction multiplication and division
Write a Python program to create a function which accept two number and return addition subtraction multiplication and division.
Solution:
def calculate(n1,n2):
a=n1+n2
b=n1-n2
c=n1*n2
d=n1/n2
return a,b,c,d
x=int(input("Enter First No :"))
y=int(input("Enter Second No :"))
#t1=calculate(x,y)
#print(t1)
add,sub,mul,div=calculate(x,y)
print("Sum is ",add)
print("Sub is ",sub)
print("Mul is ",mul)
print("Div is ",div)
Output/ Explanation:
Enter First No :10
Enter Second No :7
Sum is 17
Sub is 3
Mul is 70
Div is 1.4285714285714286