Question: Write the Python code to implement the function scores(d), where d is a dictionary representing student scores. The keys in d are strings representing student
Write the Python code to implement the function scores(d), where d is a dictionary representing student scores. The keys in d are strings representing student names, and the values are dictionaries. Each of these inner dictionaries has categories (like 'Math', 'Science', 'English') as keys, and scores (as integers) in those subjects as values. The function returns a new dictionary with each category as keys and the average score of all students in that category as values. scores_dict = { 'Alice': {'Math': 90, 'Science': 85, 'English': 95}, 'Bob': {'Math': 80, 'Science': 90, 'English': 85}, 'Charlie': {'Math': 85, 'Science': 95, 'English': 80} } >>>scores(scores_dict) { 'Math': 85.00, # Average of Math scores 'Science': 90.00, # Average of Science scores 'English': 86.67 # Average of English scores
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
