Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

########################################################## # 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1. In what ways has flexible working revolutionised employment?

Answered: 1 week ago