In this week's assignment you will look at two sports themed problems that require conditionals to get the "correct" answers. You should write these two functions using IDLE and saved in a file called "pa8.py".
Customer Request #1 ( passerRating() - a non-fruitful function )
You are contacted by Jacques Strap, who is the statistician for the football team at Whatsamatta U. 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 compare two quarterbacks to compare their abilities as a passer.
To calculate the passer rating you need five pieces of information:
To calculate the passing rating used in the NFL you:
This final result is their passer rating.
FINALLY, 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.
Write a function called passerRating() that:
To give you some numbers to work with, here are some stats through this week of the 2017 NFL football season
Customer Request #2 (leadIsSafe() - a fruitful function)
You are contacted by Marge Inovera, who is the statistician for the basketball team at Whatsamatta U. She notices that the team gets a lead and then starts celebrating too early and then blows the lead in the end (and it is really embarrassing to dump Gatorade on the coach only to later lose the game).
She points you to an article about a statistical technique used to predict if a basketball team holds enough of a lead that they are finally expected to actually win the game. Basically the technique is as follows:
Write a Python function that:
Using these four pieces of information the program should calculate whether the lead is safe or not and print an appropriate message either way.
Please notice that while this isn't too difficult in the end, there are several conditions that need to be considered since you are entering the score based on home/away and the calculation that I describe is based on winning/losing. Therefore, you need to test with several combinations and make sure that you are representing the correct calculations.
As we have done for the last few weeks, you should submit both paper printout for comment and electronic copies for execution: