Lab14
Analyze customer data
 

 


Overall Background

While true analysis of customer data is normally done in a proper database with proper database queries, we can ask and answer a remarkable number of simple questions using a simple text file of data and some basic code that uses lists and/or dictionaries to help us organize the data in that file.

In this assignment you will be working with a file of 30,000 fake customers. (Yes, it really is fake information which was generated randomly, so no trying to sell it after class! Heh.


In order to complete this assignment, you should create a file called lab14.py. Complete the following steps in the order listed. 

  1. Add comments and the printName() function:

    Create typical header comments and place them at the top of your lab14.py file. Add the typical printName() function that prints your name(s). In addition, be sure to write function comments for all functions in this lab, including the printName() function you just added.

  2. Write the getStateDistribution() method:
  1. Write the getColumnDistribution(filename,columnNum) method.
  1. Write the getBirthYearDistribution() method.

...

 

 

BONUS - Revise the getColumnDistribution(filename,columnNum) method.

It's a pain to have to know which column number we want to analyze.  Sometimes I know what the header is, but not what the column number is.

Revise getColumnDistribution() from part 2.  It should CONTINUE to work EXACTLY as it did before.  That is, it should work when I pass in a string for a filename and an integer for the column number.  However, IN ADDITION (that was a lot of capitalized words in one paragraph) it should work if I pass in a string as a filename and a string as a column header.  In this case, your code would look at all of the headers to see if  this string is one of the headers.  If it is, it uses that column number:

If it isn't, then it prints an appropriate message:

 

Review your textbook for how to find out what type a particular variable is holding.

 

 

Final Submission

This week I will again ask you to submit your code for electronic grading, using the eLearning submission system. 

Follow the directions on the system to select the appropriate course and assignment and submit

If you worked with a partner, make sure that both you and your partner's names are in the comment header at the top of the file and in the printName() function.