# 19/19 "Choose any argument you like". What's an "argument"?

#1

In the final part of the Functions lesson the instructions tell me that I can use any argument in the function being defined. Because the code seemed to be about identifying the type of the argument, I put in the integer of “-138”. After several error messages, I gave up and looked at the code. This is what was revealed:

def distance_from_zero(num):
if type(num) == int or type(num) == float:
return abs(num)
else:
return “Nope”

This code completes the final part (19/19) of the Functions lesson. I replaced the argument “num” with what I had initially tried (-138, and additionally 138, 123 and some others) and this is the error I got:

File “python”, line 1
def distance_from_zero(-138):
^
SyntaxError: invalid syntax

I believe there is a possibility that I’m not quite clear on what an “argument” is, in this case, and then also how that differs from a “parameter”. Is there any reason why the code works with “num” and not some other argument, say, “…any argument [I] like”?

Thanks

#2

look at this code:

``````# function definition with parameter
def example(parameter):
print parameter

# function call with argument
example("argument")
``````

so when we declare the function, we define a parameter. The parameter is going to receive an argument from the function call, so under the hood, this is happening:

``````parameter="argument"
``````

which is why the parameter has to be a valid variable, otherwise you get an error given the assignment of argument to parameter will fail

#3

thank you. so ‘num’ is a parameter that takes an argument in the form of a number that is either an integer or a float. i couldn’t recall that detail it seems.
the argument can also be a string or boolean, why wouldn’t that be possible? Then the function uses `type()` to determine if the argument is float or integer.