2

I am a beginner in python programming and recently i came across functions,parameters,arguments and...

I have done a lot of research on Parameters and Arguments(Even checked the answers of similar past questions on StackOverflow)but i couldn't get their meanings.

Some say,parameters are variables which we give them to functions while we are defining them and arguments are values that are passed in function once we given them to the function in order to run the function.While some other say no,it's not like that.Parameters and Arguments are same and do the same task...

Can anyone tell me the meaning Parameters and Arguments in a clear way?

Are Parameters and Arguments considered variables?

For what kind of purpose do we use them?

Please don't explain too much complicated,i am a beginner.

Thank you so much.

1
  • 1
    For almost any definition you'll find a contrarian who insists the definition is wrong (or should be changed in some gravely important sense of should). Don't worry, the distinction you found is okay, though it is not universally adhered to (partly because it's rarely terribly useful once you understand the difference between variables and values). Commented Jun 23, 2014 at 13:54

2 Answers 2

6

Per the official documentation:

Parameters are defined by the names that appear in a function definition, whereas arguments are the values actually passed to a function when calling it. Parameters define what types of arguments a function can accept. For example, given the function definition:

def func(foo, bar=None, **kwargs): pass 

foo, bar and kwargs are parameters of func. However, when calling func, for example:

func(42, bar=314, extra=somevar) 

the values 42, 314, and somevar are arguments.

The glossary defines them as:

  • Argument: A value passed to a function (or method) when calling the function.
  • Parameter: A named entity in a function (or method) definition that specifies an argument (or in some cases, arguments) that the function can accept.

Python doesn't really have "variables" like some other languages - it has "names" referring to "objects". See e.g. "Code like a Pythonista" and "Facts and myths about Python names and values".

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for giving your time.So all the thing that you are saying is : A Parameter is something that we need to give the function while defining it in order to construct the function?And an Argument is something that we need to put among the parentheses in order to run the function?
@user3722727 we don't need to - you can define a function without parameters. However, a function defined without parameters can't accept any arguments. And if a function does define parameters, arguments must be provided for those parameters that don't specify default values.
Default values ? What are they ?
@user3722727 e.g. bar=314 - if you don't specify an argument for that parameter, it will take the value of 314 by default. You should probably read the documentation on function definition and/or the tutorial on functions.
I understood.Thank you for your answers as well as your patience
1

Take it this way:

Parameter: A parameter represents a value that the procedure expects you to pass when you call it. The procedure's declaration defines its parameters.

Argument: An argument represents the value that you pass to a procedure parameter when you call the procedure. The calling code supplies the arguments when it calls the procedure.

Example:

int add (int value1, int value2) // Here value1 and value2 are PARAMETERS. { return value1+value2; } 

Now while calling the function

answer = add(2,3); // Here values 2 and 3 are ARGUMENTS. 

Same goes with Python, while declaration, they are parameters, while calling they are arguments.

Some may differ with what i have written, but this is how it is actually known in programming world.

2 Comments

A non-Python code example probably isn't very helpful for the OP.
If he had started with some other language, he would have posted the same question i guess. :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.