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

Enter First No :10

Enter Second No :7

Sum is  17

Sub is  3

Mul is  70

Div is  1.4285714285714286

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz