Write a function that will accept a list as a parameter


Part 1: Write a function take a file name as a parameter. This function will open the given file for reading and then read each line of the input file and put each line into a list. If the user passes the name of a file that doesn't exist you should catch the exception that is thrown by the open() function and return an empty list. If a valid file name is passed this function will return the list that is created.

Part 2: Write a function that will take a list as a parameter. This list will be the list from the previous function. This function will take each element of that list and calculate the Quarterback rating for each QB in the list. You will want to use the float() function instead of the int() function to convert strings to numbers. For each line you will create a tuple where the first element of the tuple is the Quarterback's name and the second element is the quarterback's Passer rating. You will then place that tuple into a list. This function will return that list. The formula for Passer Rating is as follows:

Part 3: Write a function that will accept a list as a parameter. This list will be the list from the previous function. This function will use the selection sort algorithm that we used earlier in the semester to sort the list according to each quarterback's QB rating. This list will be sorted so that the highest QB rating is at the top instead of the lowest QB rating. Remember, you are sorting the tuples, not JUST the qb ratings. You should end up with a list of tuples that is sorted by QB rating and each tuple will have the name and rating for a quarterback. Remember, since lists are pass by reference you will not need to return the list from this function. Do NOT use built in sorting functions

Solution Preview :

Prepared by a verified Expert
Macroeconomics: Write a function that will accept a list as a parameter
Reference No:- TGS01696201

Now Priced at $30 (50% Discount)

Recommended (99%)

Rated (4.3/5)