Parameter Question


#1



https://www.codecademy.com/courses/python-beginner-nzzVa/1/2?curriculum_id=4f89dab3d788890003000096


Why does it lets me pass the m, n values to the x , z parameters when the function prints out the function(m,n)?


m = 5
n = 13
# Add add_function here!
def add_function(x,y):
    return x+y


print add_function(m, n)


#2

you supply m and n as arguments at function call, so the values of m and n gets copied into the parameters (x and z)

this way, you can call the function multiply time with different values:

m = 5
n = 13
# Add add_function here!
def add_function(x,y):
    return x+y


print add_function(m, n)
print add_function(12,20)

#3

Thanks for the fast and helpful response. That is a actually a very helpful fact that makes life easier. Thanks!!!!


#4

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