Outline for November 21, 2012
Reading: none
Assignment Due: Wednesday, November 30, 2012 at 11:59 PM
- Review of slicing, var[start:end]
- Value at index end not included in slice
- If omitted, start value defaults to 0 and end value defaults to last index + 1
- Can use negative index
- Example program [strstuff.py]
- Recursion review
- Key point: Function must call itself within its own body — if it doesn’t do this, it is not recursive
- How to do it
- Example 1: length of a string [recfun.py]
- Example 2: only alphabetic characters in a string [recfun.py]
- Example 3: find largest integer in a list of integers [recfun.py]
- Example 4: make a string from the words in a list [recfun.py]
- Example 5: reverse a string [recfun.py]
A PDF version is available here.
|
ECS 10, Basic Concepts of Computing
Fall Quarter 2012
|