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 studentid: 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
b Methods: All return results in a tuple including TRUE
iinitself name: str studentid: 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
enrollself coursename: 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. addgradeself coursename: 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 getgpaself: 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.
strself: 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
