I am not sure if it possible to pass the output of two different functions in another function. Ie output of def A() and def B() are to be passed in to def C().
to make it easy to understand, I chose the following problem as an example.
Problem: I want to Add the product and division of two numbers. For that I made three function
def product(a,b):
M=a*b
def division(a,b):
D=a/b
Now I want to add M and D and the result will be (a*b) (a/b).
for this I made another function named add to get the sum
def add(M,D):
X=M D
print(X)
But didn't find any way to pass M and D in the add .
CodePudding user response:
You need to return
a result from your functions, and then call them in the definition of add
def product(a,b):
M=a*b
return M
def division(a,b):
D=a/b
return D
def add(a,b):
return product(a,b) division(a,b)
CodePudding user response:
Why can't you simply call the functions in add?
def add(a, b):
return product(a,b) division(a,b)
CodePudding user response:
def product(a,b):
return a*b
def division(a,b):
return a/b
def add(m, n):
return m n
add(product(10,2), division(10,2))