Outline for April 24, 2009

Reading: §6.3–6.4


  1. Passing values to functions
    1. Formal parameters in subject definition
    2. Actual parameters (arguments)
    3. Matching arguments to formal parameters
    4. Local variables
  2. Returning values from functions
    1. Use of “return” statement
    2. Passing values back through parameters (cannot do it directly; more later)
  3. How Python does function calls
    1. Caller suspends execution at point of call, remembers where it left off
    2. Formal parameters assigned values from actual parameters
    3. Execute function body
    4. Return control to where caller left off
  4. Example: acronym
    1. Print first letter of word (see fw.py)
    2. Split line of text into words (see lines.py)
    3. Acronyms (see acronym.py)
  5. 5. Example: averages
    1. Add n numbers (see addup.py)
    2. Average (see average2.py)