# Programming Assignment #10

## Analyzing the Quarterbacks in the NFL

### Introduction

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:

• Writing to a file
• String manipulation
• Basic mathematical operators
• Conditionals
• Iteration

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.

### Customer Request

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:

1. 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 25)

2. Adjust each of the sub stats:
• If any of the stats (A, B, C, or D) is above 2.375 you should set it to 2.375
• If any of the stats is below 0 you should set it to 0

3. 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 football season

 Name Attempts Completions Yards TD Interceptions Rating Prediction Drew Brees 248 175 1951 11 4 101.7 Great Matt Ryan 232 153 1844 9 6 92.3 Good Eli Manning 260 167 1600 10 5 86.1 Mediocre Ben Roethlisberger 275 168 2062 10 9 82.7 Bad Fake Player 365 312 312 312 51 79.2 Bad

### NEW Requirements

Jacques wants is a program that will:

1. Be in a file called pa10.py
2. Be in a function called compareQBs()
3. 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"]
4. For each Quarterback listed it should calculate their passer rating given the formula above.
5. and their overall evaluation (great, good, mediocre, bad)
6. Write a file called "qb_passer_ratings.csv" which contains each :
1. QB's name
2. team
3. passer rating
4. the evaluation of their season (great, good, mediocre, bad)

Suggestions

1. 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).
2. Wrap part one in a loop which is being fed data from the data file.  At this stage, just print results to the screen
3. Finally, work in the code to write to an output file.

Final Submission