oliviano
11/21/2018 - 1:14 AM

functions

functions help

# PASSING ARGUMENTS TO A FUNCTION ( UNPACKING A LIST )
>>> list(range(3, 6))            # normal call with separate arguments
[3, 4, 5]
>>> args = [3, 6]
>>> list(range(*args))            # call with arguments unpacked from a list
[3, 4, 5]


# with tupple:
def square(x,y):
    return x*x, y*y

t = square(2,3)
print(t)  # Produces (4,9)
# Now access the tuple with usual operations

def square(x,y):
    return x*x, y*y

xsq, ysq = square(2,3)
print(xsq)  # Prints 4
print(ysq)  # Prints 9  
# Tuple has vanished!