On beyond strings


def 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)

This is the original code. I am not clear about the difference between with print and return. Please help! Thanks tons!


let's say we have a simple function:

def multiply(a,b):
    return a * b

Return actually gives you something in return, we can see this beautiful in this code:

result = multiply(5,4)

now we made a variable result which holds the result of 5*4 (20), which we can prove:

print result

on the other hand, if you just use print inside the function, it will just print 20 to the output. So, print just show something in the output window, returns give you something back, does this help?