Question: 2 . In a file student.py create class definitions as indicated below. a . Define a class called Student with instance variables for the student
In a file student.py create class definitions as indicated below.
a Define a class called Student with instance variables for the student ID int student's name, gpa a number between and displayed as float rounded to decimal place and courses the number courses used for gpa calculation and. When creating an instance of the class, default values of 'unknown'
COMP : Programming for Beginners II
Assignment #
This material is copyrighted! Do NOT enter or share any part of it online or with anyone outside the class.
and can be used for name, gpa and numcourses respectively; but the studentID must be specified. All instance variables should be considered 'private'
b Write the following methods for this class:
i init # create and parameters
ii getCourses # returns current value for number of courses
iii. addmark # user specifies a course mark int between and to be included in the gpa calculation. Note: value of courses must be incremented as well when a mark is added, but cannot be more than If the gpa is already based on courses, a suitable message should be displayed to the user. The function returns the gpa for the student after any update
iv delmark # user specifies a course mark int between and to be excluded from the gpa calculation. Note: value of courses must be decremented as well, but cannot be less than If the current gpa is based on courses, a suitable message should be displayed to the user.
v str # shows info in format: studentIDname: gpa.
c Define overlinemathrmaunderlines u b c l a s s of Student called GradStudent, which has another instance variable called extra, that specifies the number of additional courses above that the student is allowed to take. The default value is
d Override the addmark method of the parent class. If current value of courses is boldsymbolc the new addmark method does the following:
i If boldsymbolcmathbf then new balance is updated regularly.
ii Otherwise, if c extra then the new mark is used calculate the updated gpa and a warning message is printed indicating how many extra courses the student has added.
iii. Otherwise, gpa update is not allowed, and a suitable message is printed.
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
