0

I just started self-learning python and have encountered these two problems: enter image description here enter image description here

To my understanding, an argument is a value to a function and a parameter is a variable whose value will be supplied when the function is called.

My answer to question #10 was incorrect and I wasn't clear about #8 either. It would be greatly appreciated if anyone could clarify my confusions about an argument and a parameter using these problems.

2
  • 1
    Weird question. I would say data is both a parameter and an argument, in both #8 and #10. Commented Jun 27, 2018 at 4:27
  • Agree, parameter and argument are often used interchangeably, e.g. google style doc string "Args: param1 (int): The first parameter.". Pep8: "Don't use spaces around the = sign when used to indicate a keyword argument or a default parameter value". If I was forced I would describe parameters as being part of the definition of a function and arguments being the values passed in. Commented Jun 27, 2018 at 4:36

2 Answers 2

2

Yes, your understanding of both argument and parameter are correct. So if you look at question 10, the data is passed into the function 'min'. that is why it is an argument.

As for question 8, data is a parameter of the function 'f'. When you want to call function 'f' in your program, you will need to provide an argument for the function.

Example code:

def hello(name): # name is a parameter return name myName = 'jack' hello(myName) # myName is an argument for function 'hello' 
Sign up to request clarification or add additional context in comments.

Comments

0

Parameters exist within a function definition and are referenced within that function. E.g. in def fun(arg): print(arg), arg is a parameter.

Arguments are passed to the function and determine what the parameter value will be when the function is called. E.g. in data=1; fun(data), data is the argument.

One of the big distinguishing features between the two is the parameters don’t have actual values until the function is called. Arguments are those values.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.