parameters vs arguments

View: New views
6 Messages — Rating Filter:   Alert me  

parameters vs arguments

by Kristin Wilcox :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm just starting to learn Python, and some of the vocabulary has me a bit confused. I was hoping someone could help me out. People were so helpful last time!

I'm reading stuff from multiple sources, and it seems to me like the words "parameters" and "arguments" are used interchangeably. But I'm not sure if this is a wrong perception, due to my lack of understanding, or if these terms are truly synonyms.

When I define, say, function example like this...
def example(x,y):

are x and y arguments? or parameters?

And when I call the function and pass it values

example(32,17) are those values arguments or parameters? I *thought* this was called 'passing arguments'...

I actually thought x and y would be referred to as arguments in both cases, but then sometimes I think I hear them called parameters.

Help? Am I missing some nuances here?

Thanks for reading!

-Kris

_______________________________________________
Tutor maillist  -  Tutor@...
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Re: parameters vs arguments

by Kent Johnson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Nov 4, 2009 at 8:08 PM, Kristin Wilcox <wilcoxwork@...> wrote:
> I'm reading stuff from multiple sources, and it seems to me like the words
> "parameters" and "arguments" are used interchangeably. But I'm not sure if
> this is a wrong perception, due to my lack of understanding, or if these
> terms are truly synonyms.

Wikipedia has a nice description:
http://en.wikipedia.org/wiki/Parameter_%28computer_science%29#Parameters_and_arguments

Short view - technically, parameters are the variables in the function
and arguments are the values given to the variables at the point of
call. So outside the function, it is more common to talk about
arguments. Inside the function, you can really talk about either.
> When I define, say, function example like this...
> def example(x,y):
>
> are x and y arguments? or parameters?

Parameters that will take on the value of the arguments passed to the function.

> And when I call the function and pass it values
>
> example(32,17) are those values arguments or parameters? I *thought* this
> was called 'passing arguments'...

Arguments.

> I actually thought x and y would be referred to as arguments in both cases,
> but then sometimes I think I hear them called parameters.
>
> Help? Am I missing some nuances here?

Not really, it is not an important distinction.

Kent
_______________________________________________
Tutor maillist  -  Tutor@...
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Re: parameters vs arguments

by modulok-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

[snip]

> When I define, say, function example like this...
> def example(x,y):
>
> are x and y arguments? or parameters?
>
> And when I call the function and pass it values
>
> example(32,17) are those values arguments or parameters? I *thought* this
> was called 'passing arguments'...
>
> I actually thought x and y would be referred to as arguments in both cases,
> but then sometimes I think I hear them called parameters.
>
> Help? Am I missing some nuances here?
[/snip]

For all practical intents and purposes, they're synonymous. But there
*is* a difference if you want to get technical about it.

As far as the terminology goes, it can depend on the language you're
using. Since a lot of programmers use more than one language, a lot of
terminology gets borrowed across language lines. Strictly speaking the
'parameter' is the variable which stores arbitrary data, that is
addressable within the function body. The specific data being passed,
is the 'argument'. For example:

def foo(arg):
   print arg

foo("spam and eggs")

The variable 'arg' in the function definition would the the
'parameter' and the value "spam and eggs" in the function call would
be an 'argument' to that parameter. ...strictly speaking. In reality,
some language texts may have a preference for one term over the other,
due to the author's background and previous languages they've used.
For all practical intents and purposes, they're synonymous and
frequently used interchangeably.

-Modulok-
_______________________________________________
Tutor maillist  -  Tutor@...
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Re: parameters vs arguments

by Alan Gauld :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


"Kristin Wilcox" <wilcoxwork@...> wrote

> I'm just starting to learn Python, and some of the vocabulary has me a
> bit
> confused.

FWIW I take great care in my tutor to highlight and explain the terminology
of programming in my tutor. I italicise new words and explain them on first
use. So it might be useful taking a look there if you find areas of
confusion.

> I'm reading stuff from multiple sources, and it seems to me like the
> words
> "parameters" and "arguments" are used interchangeably.

This is a confusing one and people often do get them mixed up.
Basically a parameter is what you call the thing used in the function
definition.
An argument is whats used  when you call the function.
Thus, at invocation, the parameter takes on the value of the argument.

This is confused futher by some text books using the term "formal argument"
instead of parameter. When you see "formal argument" it does just mean a
parameter. Fortunately this usage is rare nowadays.

> When I define, say, function example like this...
> def example(x,y):
>
> are x and y arguments? or parameters?

parameters

> And when I call the function and pass it values
>
> example(32,17) are those values arguments or parameters? I *thought* this
> was called 'passing arguments'...

arguments

HTH


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 


_______________________________________________
Tutor maillist  -  Tutor@...
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Re: parameters vs arguments

by binto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Parameter is what used to give/call value in function.
Argument is what used to give/call value in command line interface.

Am I correct??...

Binto

-----Original Message-----
From: tutor-bounces+binto=triplegate.net.id@...
[mailto:tutor-bounces+binto=triplegate.net.id@...] On Behalf Of Alan
Gauld
Sent: Thursday, November 05, 2009 2:08 PM
To: tutor@...
Subject: Re: [Tutor] parameters vs arguments


"Kristin Wilcox" <wilcoxwork@...> wrote

> I'm just starting to learn Python, and some of the vocabulary has me a
> bit
> confused.

FWIW I take great care in my tutor to highlight and explain the terminology
of programming in my tutor. I italicise new words and explain them on first
use. So it might be useful taking a look there if you find areas of
confusion.

> I'm reading stuff from multiple sources, and it seems to me like the
> words
> "parameters" and "arguments" are used interchangeably.

This is a confusing one and people often do get them mixed up.
Basically a parameter is what you call the thing used in the function
definition.
An argument is whats used  when you call the function.
Thus, at invocation, the parameter takes on the value of the argument.

This is confused futher by some text books using the term "formal argument"
instead of parameter. When you see "formal argument" it does just mean a
parameter. Fortunately this usage is rare nowadays.

> When I define, say, function example like this...
> def example(x,y):
>
> are x and y arguments? or parameters?

parameters

> And when I call the function and pass it values
>
> example(32,17) are those values arguments or parameters? I *thought* this
> was called 'passing arguments'...

arguments

HTH


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 


_______________________________________________
Tutor maillist  -  Tutor@...
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@...
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Parent Message unknown Re: parameters vs arguments

by binto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

I understand now…

 

Thanks

Binto

 

From: ALAN GAULD [mailto:alan.gauld@...]
Sent: Friday, November 06, 2009 7:41 AM
To: BINTO
Subject: Re: [Tutor] parameters vs arguments

 

 

> Parameter is what used to give/call value in function.
> Argument is what used to give/call value in command line interface.
>
> Am I correct??...

No.

parameters are what you use when you create the function definition.

For example

 

def f(x):

    return 2*x

 

x is the parameter.

 

Now when I call f() I must pass in a value (or variable with a value). 

The thing I pass in when I call f() is the argument.

 

f(2)

 

2 becomes the argument for this particular call to f.

The parameter x of f takes on the value 2 during this particular invocation.

 

z = 7

f(z)

 

z is now the argument of f for this invocation.

The parameter x takes on the value 7, which is the value of the argument, z

 

x is always the parameter of f() but the argument can change 

each time you call f()

 

HTH,

 

Alan G.


_______________________________________________
Tutor maillist  -  Tutor@...
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor