Question
Python 3 Use the file exam_grades.csv. For this problem, you should have a menu that asks the user if they want to know the highest
Python 3
Use the file exam_grades.csv. For this problem, you should have a menu that asks the user if they want to know the highest grade, the lowest grade, the average grade, or if they want to search for a grade. Your function should then output the result.
Example:
>>> checkGrades()
What would you like to search for?
Press 1 for the lowest grade.
Press 2 for the highest grade.
Press 3 for the average grade.
Press 4 to search for a grade.
Enter a choice: 2
The highest grade is 100.
>>> checkGrades()
What would you like to search for?
Press 1 for the lowest grade.
Press 2 for the highest grade.
Press 3 for the average grade.
Press 4 to search for a grade.
Enter a choice: 3
The average grade is 75.3.
>>> checkGrades()
What would you like to search for?
Press 1 for the lowest grade.
Press 2 for the highest grade.
Press 3 for the average grade.
Press 4 to search for a grade.
Enter a choice: 4
Enter a number to search for: 78
The grade 78 was present.
>>> checkGrades()
What would you like to search for?
Press 1 for the lowest grade.
Press 2 for the highest grade.
Press 3 for the average grade.
Press 4 to search for a grade.
Enter a choice: 4
Enter a number to search for: -3
The grade -3 was NOT present.
Write a function called checkGrades() does the following:
1. Reads in the contents of exam_grades.csv and stores the contents inside a string
2. Prints the above menu
3. Outputs the results of the user's choice
Just like you did with the getChoice() situation above, when opening the file and readings its contents, you must also delegate this task to its own function. For example, consider having a function called: getFileAsString(filename) that opens the file "filename", reads in the contents, and then returns all of the contents as a string. So for example: getFileAsString('exam_grades.csv') would return all of the contents inside that file as a string.
If the user chooses the average grade, Python will probably give at least 2 decimal places. This is fine. For 2 bonus points, look up how to control the number of decimal places for a value, and limit it to 1 decimal place.
This is what the CSV text looks like:
59,85,96,76,69,93,60,91,63,71,96,65,53,90,77,54,88,58,73,51,93,57,98,68,51,51,78,63,77,89,88,92,74,54,61,99,90,57,97,59,64,82,83,75,66,88,71,62,91,79,61,69,87,68,78,68,81,76,84,82,54,62,60,84,57,63,78,51,85,95,68,57,76,73,93,96,90,77,53,60,70,95,87,82,61,95,77,59,66,78,57,83,52,71,92,59,78,58,56,71,89,68,89,78,100,58,72,73,67,84,84,94,59,90,79,62,92,90,52,50,69,84,95,69,68,96,85,52,70,65,80,75,50,64,56,67,95,58,76,70,59,78,72,97,75,57,72,50,99,60,92,66,73,75,60,90,67,93,50,74,60,61,58,52,68,58,89,51,61,89,65,65,73,71,69,66,63,98,60,99,94,96,74,93,76,89,80,51,93,51,83,94,95,79,94,87,92,96,52,95,57,63,50,56,71,60,67,71,66,68,89,63,65,97,77,58,77,87,85,73,57,89,86,60,73,84,99,58,89,90,90,70,89,97,85,58,78,95,58,88,94,86,53,98,58,86,77,57,87,52,94,95,50,50,97,85,100,97,50,72,83,83,67,97,69,57,66,79,81,56,81,99,50,75,81,67,89,55,100,88,79,90,72,62,82,81,88,59,75,95,94,76,57,75,64,61,74,69,88,55,91,73,86,66,79,52,82,58,79,53,88,98,63,61,100,93,75,95,58,88,73,61,56,94,67,50,65,78,81,94,83,76,83,64,85,61,75,98,54,82,51,60,82,74,73,62,59,78,60,92,74,67,80,93,77,76,52,85,70,82,88,86,87,68,60,55,62,69,74,83,79,83,85,58,68,63,100,63,77,92,55,64,85,89,88,71,79,92,95,79,94,59,91,74,79,65,63,92,98,70,80,56,99,72,73,97,56,77,96,59,83,80,84,86,74,61,93,74,81,87,76,60,84,99,58,70,100,57,85,66,83,69,95,98,77,92,56,56,90,100,97,82,62,80,89,57,89,97,59,100,78,78,99,79,71,82,67,65,68,66,61,74,97,97,53,97,71,73,57,69,50,88,60,54,73,88,74,64,75,95,82,73,68,57,78,79,71,53,88,81,79,90,64,94,71,97,99,83,84,76
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started