[Tutor] Help!
Alan Gauld
alan.gauld at yahoo.co.uk
Mon Jan 4 16:48:19 EST 2021
On 04/01/2021 21:18, Cameron Simpson wrote:
> The word you want is "parameter". When you write a function like this:
>
> def mul(a, b):
> return a * b
>
> the variables "a" and "b" come from the function argumments, generally
> called "parameters". When you call it, for example:
>
> x = mul(3, 2)
>
> the function parameters "a" and "b" take on the values 3 and 2
> respectively,
This is one bit of computing terminology that often confuses
learners (and sometimes more experienced practitioners who
should know better!)
In the example above a and b are *parameters* of the function mul()
They are the placeholders for values passed by the functions callers.
When the function is called as mul(3,2) the values 3 and 2 are the
functions *arguments*. So arguments are passed into a function when you
call it and the parameters are the parts of the function definition
which take on (or receive) the values of those arguments.
It may sound like a subtle distinction but when discussing how functions
are defined and used the separation of terms becomes significant.
Note:
Just to really confuse things, some text books use the term "formal
arguments" instead of parameters. Personally I find "formal arguments"
and "arguments" far too close for comfort so I always use
parameters/arguments.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list