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 get_file_data that takes a variable file_to_read as an parameter that Combine section1 and section2 lists into a combined list
Repeat steps 4.1.a -4.1.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 section3.txt 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 file_to_read
Uses a loop to read contents of the file, convert each line to an integer, and add it to the
list
Closes file_to_read
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 7 CT Prog exercise to display the average as a
letter grade next to the number.
opt 1(Easy) You can just cut and paste the function definition into this assignment
opt 2(advanced) Copy your Text Chapter 7 CT Prog exercise into this assignment's folder
and import it.
Create a function called get_results 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 convert_score_to_letter 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 Ch6 CT Prog)
Add appropriate defensive logic (what if count of scores is 0?)
if the count is 0 your function should return 0,0,?'na' as a tuple
Create a main function that does the following:
Process section1.txt
Calls get_file_data with 'section1.txt' as the argument and stores the resulting list
Passes the returned list to get_results() and stores the results as section_count,
section_average, and section_grade
Displays the results as shown in the output example below
Process section2.txt
Repeats step a-c above for section2.txt
Process combined list
Combine section1 and section2 lists into a combined list
Repeat steps 4.1.a -4.1.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 section3.txt 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.
Create function called get _ file _ data that

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!