Return


#1

Hello,
Please can you explain the meaning of return in Python

ef biggest_number(*args):
print max(args)
return max(args)

def smallest_number(*args):
print min(args)
return min(args)

def distance_from_zero(arg):
print abs(arg)
return abs(arg)

biggest_number(-10, -5, 5, 10)
smallest_number(-10, -5, 5, 10)
distance_from_zero(-10)

Thanks
Please leave the following link in the post so we can find the unit module, else replace it with a link to the exact lesson:

Strings and Console Output


#2

return returns (hands back) a value, which we can then store in a variable:

def smallest_number(*args):
    print min(args)
    return min(args)

x = smallest_number(1, 2, 3)
print x

or print directly by putting a print statement in front of the function call


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.