Question
########################################################## # CORRECT THE CODE PROBLEMS IN THE PROVIDED CODE Answers/output values should be: student1: 82.50 student2: 90.00 student3: 70.00 Class average: 80.83 # REMEMBER
########################################################## # CORRECT THE CODE PROBLEMS IN THE PROVIDED CODE
Answers/output values should be:
student1: 82.50
student2: 90.00
student3: 70.00
Class average: 80.83
# REMEMBER TO LEAVE YOUR DEBUG STATEMENT(S) IN THE CODE!
##########################################################
""" Purpose: 1. Calculate & print the average grade for each student 2. Calculate & print the average grade for the class (3 students) """
student_grades = { "student1": [80, 81, 82, 83, 84, 85], "student2": [85, 85, 95, 95, 90, 90], "student3": [75, 65, 75, 65, 75, 65] }
student_count = 0 student_total = 0 student_avg = 0
class_total = 0 class_avg = 0
for student, grades in student_grades.items(): for grade in grades: student_total = grade # Calculate student average student_avg = student_total / len(grades) # Display each student's name and average print(f'{student}: {student_avg:.2f}') student_count += 1
# Add student avg to class total class_total += student_avg
# Calculate class average class_avg = class_total / student_count
# Display class average print(f'Class average: {class_avg:.2f}')
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