CSI PA10

Tracking the Greats of the NBA


Code due by Wednesday, April 18th at 9:00 AM


The purpose of this assignment is to give you more practice with functions, files, and lists while using a real data set populated with career data from NBA players! For the last assignment, we made a hierarchical solution tree based on knowing a few details about this programming problem. Instead of making you code up a program based on your tree alone, I would like you to instead follow the directions below. (You are coding a solution according to my hierarchical solution tree.) At the end of the assignment, I would like you to compare this program design with the tree you created in homework 9 (see Part 4 below) for 5 points.

Remember, before you begin this project, review the new function commenting styles that I expect. Please create the function comments before beginning the actual coding.


Getting Started

Please download one of the following:

  1. If you are using a Windows computer, download this file:  player_career.csv
  2. If you are using a Mac or Linux computer, download this file: player_career_mac.csv
  3. Copy this file into the same directory where you will be writing your python program for this assignment

The format of this file is easy to understand. Open the file by right clicking on the file and selecting "Open With" and selecting a text editor of some kind like Notepad++ or Wordpad.  The first line tells you the names of all the columns. (To understand the meanings of each of the abbreviations, look at the page: here.) After that, each line’s data corresponds to one player’s career statistics. Each field is separated by a comma.   

Notice that, in addition to the very first line, which is the header information, there appears to be a blank line followed by a line of "garbage" at the bottom of the file.  This will become an issue later in the assignment.


Your Assignment, Part 1

  1. Begin by creating a file called pa10.py.
  2. In this file create a function called readData().  This function should:
  3. Write a function called points().  This function should:
  4. Write a function called main().  This function should:

When you are all done you should be able to load and invoke main() from the shell and get a response that looks like the following:

 


Your Assignment, Part 2

  1. Write additional functions called turnovers() and freethrows().  These functions should work just like the points() function does.  That is, they should take in the main data list, process each player in the list to make appropriate lists, and return a list of these lists. 
  2. You should also modify your main() method so that it prints the ten players with the largest number of each of these items.  When I run this function I should see a long screen dump of the top 10 players in each of these three statistic categories:

 


Your Assignment, Part 3 - The Efficiency Statistic

Each of the above statistics is interesting, but it only tells us how good a player is at one specific statistic.  How do many NBA coaches quickly evaluate a player's overall game performance? They check his efficiency.  This statistic is something like the QB passer rating we calculated earlier in the course.  It is a calculation that tries to assign a number to how "well" a player played the game.  Higher numbers mean a better performance from that player.

NBA.com evaluates all players based on the efficiency formula indicated below (and shown on the aboutstats.htm page).  In this project, we will follow this efficiency formula. Since we are not evaluating a player based on one game, we need to divide the total efficiency by the number of games the player played.  So the formula is:

The abbreviations on the right hand side of the equation correspond to the fields in the statistics file.  Again, you can check out the the meanings of each of the abbreviations at:  http://www.databasebasketball.com/about/aboutstats.htm

  1. Create a function called efficiency().   This function should behave very similarly to the functions you wrote in parts 1 and 2 in that it should:


Your Assignment, Part 4 - Design

This design tree would have 6 modules, one for each function -- main, readData, points, minutes, rebounds, and efficiency. Compare this design with the design tree you created in homework 9, and write two paragraphs stating:


Helpful Hints:

  1. Remember the split() function, which takes as an argument the character to split on, and returns a LIST of STRINGS
  2. Pay attention to the type of data you are working with.  Don't forget to convert Strings to numbers or vice versa as needed:
  3. A 2-item list would be:
    	mylist = [x,y]

    To append this list to a list you can just say myList.append(mylist). Then to access the different items in the list you index into the list twice, so for example if you appended the above list as the first item in a list:
    myList[0][0] would return x
    myList[0][1] would return y

  4. Since there are so many fields, do some testing (E.g. output some parsed data) to make sure that you get the correct data.
  5. List’s sort function and reverse function should be useful.

Final Submission

To upload your homework for grading, log on to eLearning, select this class, and navigate to the "Assignment Submissions" area. Click on the "Programming Assignment 10" folder and upload the python file and paragraphs in the designated location.

Please submit these: