Question: You are required to create a Python class named Student that models a student. The class should have the following attributes and methods: a .

You are required to create a Python class named Student that models a student. The
class should have the following attributes and methods:
a. Attributes: Add comments including the date of creation
i. names: A string representing the students name.
ii. student_id: An integer representing the students unique
identification number.
iii. courses: A list of strings representing the courses the student is
enrolled in.
iv. grades: A dictionary where the keys are course names and the values
are the grades the student has received in those courses. All minus 2.
b. Methods: All return results in a tuple including (TRUE)
i.__init__(self, name: str, student_id: int): Initializes a new Student
object with the provided name and student ID. The courses list should
be empty, and the grades dictionary should be empty when a student
ii. object is created. All methods should include comment #data valid
enroll(self, course_name: str): Enrolls the student in a new course by
adding the course name to the courses list. If the student is already
enrolled in the course, the method should do nothing.
iii. add_grade(self, course_name: str, grades: float): Adds a grade for a
specific course to the grades. dictionary. If the student is not enrolled
in the course, the method should raise a ValueError with the message
Student is not enrolled in the course. Sir.
iv. get_gpa(self): Calculates and returns the students GPA as the
average of all grades in the grades dictionary. If the student has no
v. grades, the method should return None.
str(self): Returns a string representation of the Student object in the
format: "Student Name: , ID: , Courses: #
".

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!