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