Outline for November 19, 2012
Reading: § 7, 14
Assignment Due: Wednesday, November 28, 2012 at 5:00 PM
- Example use: linear search [linsearch.py]
- Example use: recursive linear search [rlinsearch.py]
- Example use: linear search using L.index(x) [linsearchix.py]
- Tuples
- Used to group data
- Like lists, but immutable
- Overview of top-down design
- Sometimes called “stepwise refinement”
- Break problem into smaller pieces, plus the “glue” to hold them together
- Do the glue first, with the smaller parts being stubs
- Do the stubs
- Step 1: the program, at a high level
- Play rock, paper, scissors against the computer
- Define goal, being specific
- Define input
- Define high-level design
- Step 2: Data representation, smaller pieces, and main program
- Define the routines as stubs
- Do main, directly from the design
- Step 3: First routine, who wins
- Test it with the main [rps-prog1.py]
- Step 4: Second routine, computer picks
- Be sure to print the result; useful later on, so a separate routine
- Again, test it with main [rps-prog2.py]
- Step 5: Third routine, user picks
- Check for errors on entry, and announce results
- Again, test it with main [rps-prog3.py]
A PDF version is available here.
|
ECS 10, Basic Concepts of Computing
Fall Quarter 2012
|