Question: Program: GradeBook.py Scenario: A high school teacher needs to track students' grades and calculate averages for reports. You are tasked to develop this system. Task:

Program:
GradeBook.py
Scenario:
A high school teacher needs to track students' grades and calculate averages for
reports. You are tasked to develop this system.
Task:
Write a Python class named GradeBook with the following components:
Fields:
grades (list of floats): A list to hold grades
Constructors:
A constructor that initializes the grades with an empty list.
Methods:
add_grade(grade ): Adds a grade to the list. If the grade is not between 0
and 100, raise a ValueError with the message "Invalid grade"
calculate_average(): Calculates and returns the average of the grades in
the list.
_ str_(): Returns a string that shows all grades and the average.
In the main method, create instances of GradeBook, add grades, calculate the average,
and handle any exceptions that arise.
Program: GradeBook.py Scenario: A high school

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!