o Click on the above link (Proj4.zip) and download Proj4.zip into your cs141 directory on your desktop.
o Open your cs141 directory from the Desktop. You should see all the lab directories, your Proj1, Proj2, and Proj3 directories, and your Proj4.zip file.
o Unzip Proj4.zip.
o Open Wing and navigate to the Proj4 directory.
o Load the Proj4.py into Wing. It should be empty. You can now write the rest of your code into this file.
o This zip file also includes a file called passers.csv. This is the data file that contains the statistical information about the passers in the NFL. The first line of this file has headers for the columns, but they are abbreviated. These abbreviations mean:
§ name - name
§ pos - position
§ team - team
§ season - season
§ g - games
§ comp - completions
§ att - attempts
§ pyds - passing yards
§ ptd - passing touchdowns
§ ptdr - passing touchdown ratio
§ py/a - passing yards / attempt - this value is not always valid
§ intc - interceptions
(Do not change the name of this file. This is the name we will use in grading your programs, so it must be the same.)
2. Echo-print all your keyboard input.
3. Open the data file for reading. Read the first line and throw away the column header information.
4. For every line in the file, strip away extraneous punctuation, and create a list of information by splitting the line at the commas.
5. Calculate the rating of this player.
6. Create a list of information about this player with the rating first (so you can sort on it), his name, year, team and attempts, and append it to a list of all players that you are maintaining. (So you are creating a list of lists of all players, but only with certain information included.)
7. After reading all the data and calculating all the ratings,close the file and sort the list in reverse order, as we are interested in those players with the highest efficiencies.
8. Print out the top 50 people in order from best to worst for all players in your list. This includes players that may have only thrown one pass in a single year. So print another list, but only include those players who threw 20 or more passes during a year. (You can do this with one procedure and pass to it the number of attempts and use that to determine who gets printed.) Look at the output specifications below to get an idea of how this should look.
9. Now you want to find the passer whose overall passer rating is the best. Reopen the file (if your closed it), or do a seek(0) and as before, create a list of lists, containing the passer's name first (concatenated together as last, first), team, completions, attempts, total yardage, touchdowns, and interceptions. Close the file. Sort this list. This creates a new list in alphabetical order with all the different years' information for a particular player together.
10. Using the above list, go through and for each person (which should all be sorted together now), add up their completions, attempts, yardage, touchdowns, and interceptions. Calculate an overall passing rating for each person. Put this information into another new list which need only contain each person's rating (first) and name. Sort this list in reverse order.
11. Print out the person with the highest passer rating along with a list of the other 19 in the top 20.
12. Calculate the other statistics noted above. Start by writing a function for each, but you should notice a pattern after writing one or two that will indicate how to write one function that you can call for each statistic. You will have to read through the original file here to get these pieces of information. I needed to write two functions here as one looked for one piece of information and the other looked for a ratio requiring two pieces of information.
13. Output this information. Again look at the output specifications below for how this should look.
14. Finally you may be interested in finding out the rating of a particular player. Ask the user if they are interested in a particular player. Answer 'y' or 'n'. If yes, ask the user to enter the person's first name, then last name. Search your list (you've made a number of them by now, so pick the one that is the most efficient for this task) looking for this person's first and last name. When you find it, print the name along with the overall passer rating. Continue to ask if they are interested in a particular player. Loop as long as the answer is 'y' (or 'Y') and quit when they answer something other than yes. NOTE: you are not looking for "N". Anything other than a 'y' or a 'Y' will terminate this loop.