Programming Assignment #10
Analyzing the Quarterbacks in the NFL
Due Date : Friday, December 1st
This assignment is a good
way to pull together lots of the ideas we have used this semester so far.
To complete the assignment you will need to be able to work with:
- Reading from a file
- Writing to a file
- String manipulation
- Basic mathematical operators
Wow, that's a lot of ideas!!!!
Actually, this assignment isn't that bad in the end, but it is a lot to THINK
about as you get started.
You are contacted by
Jacques Strap, who is the statistician for the NFL. He wants to hire you to write some code to
save him from performing a bunch of tedious calculations.
Background (Repeated from PA8)
In football there is a statistic for quarterbacks called the "passer rating."
While this only evaluates their abilities in the passing portion of the game (it
doesn't take into account their ability to run, their ability to win, their
ability to not fumble, etc.) it is often used as one way to analyze two
quarterbacks and compare their abilities as a passer.
To calculate the passer rating you need five pieces of information:
- the number of passes attempted
- the number of passes completed
- the total number of passing yards
- the number of touchdowns thrown
- the number of interceptions thrown
To calculate the passing rating used in the NFL you:
- Calculate four sub stats:
- Completion stat (A) = "completions per attempt" times 100 - 30, all
divided by 20
- Yards stat (B) = "yards per attempt" - 3, all divided by 4
- Touchdown stat (C) = "touchdowns per attempt" times 20
- Interceptions stat (D) = 2.375 - ("interceptions per attempt" times
- Adjust each of the sub stats:
- If any of the stats (A, B, C, or D) is above 2.375 you should set it
- If any of the stats is below 0 you should set it to 0
- Calculate the passing rating by taking the sum of all four adjusted
values, dividing by 6, then multiplying by 100
This final result is the passer rating.
Furthermore, in general you can use this number to predict how good of a year the QB was having. Scores at 85 or worse mean the player was having a BAD
year. Scores above 85 are MEDIOCRE. Scores above 90 are GOOD, and
scores above 95 are GREAT.
To give you some numbers to work with, here are some stats through this week of the 2017 NFL
Jacques wants is a program that will:
- Be in a file called pa10.py
- Be in a function called compareQBs()
- When this function is run it should ipen the data file containing QB statistics from the 2013 season (I
downloaded this from ESPN).
- qb_data.txt [To save this RIGHT-CLICK on the link and select "save link as"]
- For each Quarterback listed it should calculate their passer rating given
the formula above.
- and their overall evaluation (great, good, mediocre, bad)
- Write a file called "qb_passer_ratings.csv" which contains each
- passer rating
- the evaluation of their season (great, good,
- Begin by ignoring file input. Start your program with five appropriately
named variables and set them to the values of one of the QBs in the table
above. Work through the math of the rating and make sure you get the
listed result. (This should be easy since this is mostly PA8).
- Wrap part one in a loop which is being fed data from the data file.
At this stage, just print results to the screen
- Finally, work in the code to write to an output file.
To upload your homework for grading, log on to the homework submission system at:
Follow the directions on the system to select the appropriate course and
assignment and submit