Q1. Write a python code that reads students' total, then print a table with the letter grades and frequencies. The progr
Posted: Wed Apr 27, 2022 3:40 pm
Q1. Write a python code that reads students' total, then print a table with the letter grades and frequencies. The program should also print a bar chart as shown below in the sample output (next page). You are required to use a dictionary to find the frequency of each letter grade. You dictionary should have the letter as the key, and the frequency as the value. Use the following predefined dictionary to map total to letter grades: grades = {90: 'A', 80: 'B', 70: 'C', 60: 'D', 50: 'F'} You are not allowed to use if statements to decide the letter grade, you should use the predefined dictionary (grades). Hint: use division to change each student total to 90, 80, 70, 60, or 50. For example: if the total is 67, this student should get D, to convert 67 to 60, perform integer division by 10. The result will be 6, now you want 6 to be changed to 60, how you could do that? Write the following functions: • read data: this method ONLY reads the students' totals, and returns a list of totals • count frequency: this method takes the total list as an argument and returns a dictionary of the grade frequencies print table: this method prints the table • print chart: this method prints the bar chart .
Sample output: How many students do you have? 10 Enter a total: 98 Enter a total: 65 Enter a total: 68 Enter a total: 55 Enter a total: 45 Enter a total: 33 Enter a total: 88 Enter a total: 89 Enter a total: 84 Enter a total: 86 Grade Frequency A 1 B 4 с 0 2 3 i ס ד WN A: * B: C: D: ** F: ***
Sample output: How many students do you have? 10 Enter a total: 98 Enter a total: 65 Enter a total: 68 Enter a total: 55 Enter a total: 45 Enter a total: 33 Enter a total: 88 Enter a total: 89 Enter a total: 84 Enter a total: 86 Grade Frequency A 1 B 4 с 0 2 3 i ס ד WN A: * B: C: D: ** F: ***