```
WEEK07: File I/O, top-down design
---------------------------------------------------------------
W: start top-down design

ANNOUNCEMENTS:
- Lab 7 due after break...want top-down design turned in first!

TOP-DOWN DESIGN:

Top Down Design is a problem solving technique where you:

2. Break it into several high-level steps
3. Iteratively break the steps into smaller steps until you have
steps that are easy to solve

in the second-level details, and so on until you can start
writing each section/function

- for example, writing a wheel-of-fortune game might start
with something like this:

pick one phrase for the game
play the game, with the chosen phrase
output the results

Each one of those could be a single function, or may need to
be broken down into multiple functions. If you think one of
the above should be a single function, sketch it out (what
arguments would it need, what would it do and how, and what
should it return). If you think one of the above (ex: play the
game) will be more than one function, do another level of
top-down design on that.

- GOALS: get main() written, decide on data structures, how data
will go to/from each function, write function stubs so we can
write and test each function, one at-a-time!

"""
J. Knerr
Spring 2011
"""
# ---------------------------------------------- #

def main():
"""
get grades, calculate stats, output results
"""
print "ave grade = %0.1f" % (ave)

# ---------------------------------------------- #

def findMax(glist):
"""
"""

# ---------------------------------------------- #

def findMin(glist):
"""
"""
return -1

# ---------------------------------------------- #

def findAve(glist):
"""
"""
return -1

# ---------------------------------------------- #

"""
given a file name, open the file, then read each line
from the file and get the grade. convert grade to a float

use split(":") to get the name and grade from each line of the file
"""
return [3,4,5]

# ---------------------------------------------- #

main()

NOTE: it doesn't do anything yet, but the structure and design are
all specified. The program runs, and I can start working on adding
each function. I can also TEST each function as I write them. Once
I know they are working, I can move on to the next function.

TEST AS YOU GO!!!

- suppose I add the findMax function:

def findMax(glist):
"""
"""
for g in glist:

- Now I can test just this function by adding test code in main():

print findMax([9,0,7,4])
print findMax([9,0,700,4])
print findMax([2,2,2,2,2,2])

STRING METHODS AND FILE I/O:

- given a file called "grades.txt" which contains these lines:

lisa     :95
jeff     :35
charlie  :88
jonathan :97
rich     :77
andy     :70
doug     :55
betsy    :100
amanda   :99

"""
given a file name, open the file, then read each line
from the file and get the grade. convert grade to a float