Question: Create function called get _ file _ data that takes a variable file _ to _ read as an parameter that Combine section 1 and
Create function called getfiledata that takes a variable filetoread as an parameter that Combine section and section lists into a combined list
Repeat steps a c above for the combined list
Output the minimum score and the letter grade for this score You can use the min
function for this
Output the maximum score and the letter grade for this score You can use the min
function for this
Verify your output looks as shown below.
Run your program again using the sectiontxt file which contains an error in the data to
make sure your program handles the ValueError exception.
Test IOError exception handling by changing the name of the file in your program to something
that does not exist.
Output Example:
does the following
Creates an empty list
Opens filetoread
Uses a loop to read contents of the file, convert each line to an integer, and add it to the
list
Closes filetoread
Returns the list of numbers
Ensure you add the appropriate exception handling inside this function
If the file can't be opened or contains errors, it should return an empty list
Add the function you wrote for the Chapter CT Prog exercise to display the average as a
letter grade next to the number.
opt Easy You can just cut and paste the function definition into this assignment
opt advanced Copy your Text Chapter CT Prog exercise into this assignment's folder
and import it
Create a function called getresults that takes a variable called scores as a parameter that
does the following:
Use a loop to calculate the count and average of the numbers in scores it should be a
list
After the loop, call your convertscoretoletter function, passing it the average you just
calculated and store the result in grade
Returns count, average, and grade as a tuple similar to Text Ch CT Prog
Add appropriate defensive logic what if count of scores is
if the count is your function should return as a tuple
Create a main function that does the following:
Process sectiontxt
Calls getfiledata with 'sectiontxt as the argument and stores the resulting list
Passes the returned list to getresults and stores the results as sectioncount,
sectionaverage, and sectiongrade
Displays the results as shown in the output example below
Process sectiontxt
Repeats step ac above for sectiontxt
Process combined list
Combine section and section lists into a combined list
Repeat steps a c above for the combined list
Output the minimum score and the letter grade for this score You can use the min
function for this
Output the maximum score and the letter grade for this score You can use the min
function for this
Verify your output looks as shown below.
Run your program again using the sectiontxt file which contains an error in the data to
make sure your program handles the ValueError exception.
Test IOError exception handling by changing the name of the file in your program to something
that does not exist.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
