Basketball Statistics
Duke basketball season just started, so let's look at some statistics from Sports Reference of the past few seasons and ask some questions about the players. The meaning of the abbreviations in the column headers are given here.
Start by snarfing the code from the class website. Alternatively, you can browse code here. This given code was developed during class reads in the given data, developing career stats for each player by summing each column (except year), and printing out the players in sorted order.
Working with the Code
In this part, write code to ensure you understand the form the data is in and how to use tuples.
- Write a function
getHighestScorerwhich takes as a parameter a dictionary of the players' stats as described above and returns a string, the name of the player who scored the most points over their career. Use the following formula to calculate a player's total number of points:FT + 3 * P3 + 2 * (FG - P3) # free throws + 3 * 3-pointers + 2 * (field goals - 3-pointers)
- Write a function
getFreeThrowPercentwhich takes as a parameter a dictionary of the players' stats as described above and returns a list of tuples of two elements, a string, the player's name and a float, the percentage of free throws made. Use the following formula to calculate a player's free throw percentage:FT / FTA # free throws / free throw attempts
- Write a function of your choice that "answers a question" using multiple columns in the given data, such as: find the player with the most points per minutes played, best points per scoring attempt, or total team fouls versus free throw attempts, etc.).
Output
In addition to the current program's output, you should then print the results of the first two problems on the next successive lines with a blank line between each answer. For the last problem, you should print the "question" you are asking on one (or more) line(s) and then the answer on the next line(s).
Submission
As an assignment, this should be done individually and submitted electronically from within Eclipse or on the web using the name lab08_basketball. Please include a README file with your submission.