[Tutor] trying to understand the logic of functions

peter hodgson py at gogol.humnet.ucla.edu
Wed Apr 7 02:15:02 EDT 2004


On Monday 22 March 2004 20:47, python_simpleton wrote that terms like
'parameter' were confusing;

here's another newbie's attempt to sort out parameter's node of terms:

1. a function is defined thus:

   def NAME(LIST OF PARAMETERS):
       STATEMENTS

2. when a function is called:

   it takes [gets passed] an argument [value or variable], 

   and returns a result [return value],
   or performs an action;

3. variables are the boxes for values;

   parameters are the variables used in the definition of a function,
   inside the parentheses, to refer to the value[s] which will be
   passed as arguments when the function is called;

4. function names, as well as the names of variables [incl.
   parameters] can be arbitrary; they are not what gets stored in
   memory and manipulated by the function when it is called; they are
   just labelled boxes;

5. statements can assign values to variables; an example is a
   statement which assigns the return value of a function to a
   variable; e.g.:

   variable = function (argument);

thus, a parameter [which is a variable] can be a function,
i.e. its result is the argument of its parent function: e.g.:

   fun1 (fun2()), or even 
   fun1 (fun2(fun3(argument)))











More information about the Tutor mailing list