Python :: Return Multiple Values From a Function

Python has the ability to return multiple values from a function call, something missing from many other popular programming languages. In this case the return values should be a comma-separated list of values and Python then constructs a tuple and returns this to the caller. As an example see the code below:

def multiplication_division(num1, num2):
return num1*num2, num1/num2product, division = multiplication_division(15, 3)
print("Product=", product, "Quotient =", division) # Product= 45 Quotient = 5.0

Leave a Reply

Your email address will not be published. Required fields are marked *