# Lab1

Learning Objectives: iteration (for loop), lists

[classmates1.py](classmates1.py)

Create a file called classmates2.py. Give it a list with the first
names of each of your classmates and use a for loop to print out each
name. 

# Lab2 (tuples, string formatting)

[classmates2.py](classmates2.py)

1. create a list of tuples (firstname, lastname, role).
2. loop over the list of rows, printing "fname lname is a role"
   with the % formatting operator


# Lab3 (conditionals, input, dicts)

[classmates3.py](classmates3.py)

1. Store list of classmates as a dict by first name => tuple row
2. get input from the user, printing out the corresponding student if
   exists, error message if not found.

  
# Lab 4 iteration (while loop), modifying dicts, sys.exit

[classmates4.py](classmates4.py)

1. wrap an infinite while loop around input 
2. If the name entered isn't found, solict input and add it to the
   dict.
3. Exit if the user enters "Quit"
   
# Lab 5 - refactoring, functions

[classmates5.py](classmates5.py)

1. define a function "print_record" that outputs a row 
   and use it for all output
2. define a function get_record that solicits user input
   and returns a firstname, lastname, role tuple. 

# Lab 6 - dict methods, zip, *args, sets

[classmates6.py](classmates6.py)

1. modify classmates5.py to print the set of unique roles before
   soliciting user input. (Hint: use dict.values, zip with *args, and
   convert the resulting column to a set for uniqueness)q
   
# Lab 7

[classmates7.py](classmates7.py) - __main__, filtering with loops

1. Starting from classmates5.py, add a main() function run by the
__main__ idiom.
2. Present a menu of user choices and take appropriate action upon
user input:
    <p>
       1. List all
       2. Search by name
       3. Add record
       4. Filter by role
       5. Quit
    </p>
3. implement Menu item #4 with a for loop and if statement. Pass the
   filtered array to the function used for menu item #1 to output a
   list.
4. Be sure to import your script (start python then 'import
   classmates7'. Notice no code runs. Inspect classmates7 with help
   and dir())

# Lab 8 - first class functions, namespace and scope

[classmates8.py](classmates8.py)

1. Use the filter builtin to implement filtering by role. How can a
   predefined function filter by user input? (Hint: a function can access
   the global namespace). Be sure to limit to valid roles.
2. Use function variables and a data structure to map menu selections
   to code blocks. Your main loop should have very few if statements
   in it.
   
# Lab 9 - fileIO, split, join, strip

[classmates9.py](classmates9.py)

1. Load data to your data structure from a csv textfile "classmates.csv" using the file builtin
2. Add a menu option to save and write data to the same file

# Lab 10 - optparse

[classmates10.py](classmates10.py)

1. add optparse argument handling to your script. Let the user supply
   a filename argument to read/write from.

# Lab 11 - doctests

[classmates11.py](classmates11.py)

1. Add doctests to your utility functions. Refactor as necesary to
   doctest filtering by role. Does thinking about testing change the
   way you write code?
2. Add a test flag to your optparse frontend to run your tests   

# Lab 12 - sort and higher order functions

[classmates12.py](classmates12.py)

Menu item #1 should allow sorting by a field the user
selects. Implement using the key parameter of the sorted function and
create a keyfunction using a closure that captures the user's input.

Adding an item to the menu should be easy as it is a data structure,
not a series of if statements.


# Lab 13 - list comprehensions

[classmates13.py](classmates14.py)
Yay for a killer feature! Filtering and modifying in the same compact
syntax - python's () sure get a workout. Discuss places to replace
filter calls or for loops with a list comprehension.

# Lab 14 - OOP

(classmates14.py)

"Rows" should be objects. Rows know how to sort themselves and print
themselves. The addressbook should be an object that knows how to
print itself and add new rows. Did switching to OOP improve your code?

