6. More than one argument - Instructions

The instructions for “6. More than one argument” are to “Define a function called add_function that has 2 parameters x and y and adds them together.”

That would be this:

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

print add_function(m, n)

That’s an odd set of instructions, because nothing is done with the summed value of x and y. Additionally, this solution is not counted as correct, because the function is supposed to return the sum of x and y. I think the exercise would be clearer if this extra step were mentioned in the instructions.

How about this?

“Define a function called add_function that has 2 parameters x and y, adds them together, and returns the total.”


It is assumed that you use return, because you must to get output from a function.

I think your statement is false. Not all functions give a return value, so it should not be assumed.

For example, a function might take a list as a parameter and modify that list directly. It then would not need to return the list in order for the changes to be reflected after the function’s operations are concluded.

Therefore, the instructions would be better with the ambiguity removed.

It usually doesn’t occur that a list is directly changed, but a copy operated on. I don’t think you ever directly change the content of a variable with functions.

m = 5
n = 13

def add_function(x,y):
return x+y

print add_function(m, n)`

1 Like

I think the instructions are wrong because there are no variables declared as x or y so what is it going to add.
By changing the functions arguments to “m” and “n” it works.

m = 5
n = 13

Add add_function here!

def add_function(m, n):
add_function = m + n
return add_function

print add_function(m, n)

Hope this helps:) Also do not forget your INDENTS

1 Like

Sorry to revive old topic here but,

I was wondering about the x,y vs m,n in the instructions and that brought me here after a little researching. It appears to me that the x and y are simply interchangeable variable placeholders that get replaced by m and n once you call them with print and tell it to use those two instead of the x and y.

Hopefully one of the code fu masters around here can tell me if this is the correct presumption.