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

2. 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 0 and 100, displayed as float rounded to 1 decimal place) and courses ( the number courses used for gpa calculation) and. When creating an instance of the class, default values of 'unknown' 0.0
COMP 2087: Programming for Beginners II
Assignment \#3
This material is copyrighted! Do NOT enter or share any part of it online or with anyone outside the class.
and 0 can be used for name, gpa and num_courses 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. add_mark ()\# user specifies a course mark (int between 0 and 100) 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 40. If the gpa is already based on 40 courses, a suitable message should be displayed to the user. The function returns the gpa for the student (after any update).
iv. del_mark ()\# user specifies a course mark (int between 0 and 100) to be excluded from the gpa calculation. Note: value of courses must be decremented as well, but cannot be less than 0. If the current gpa is based on 0 courses, a suitable message should be displayed to the user.
v. str ()\# shows info in format: studentID(name): gpa.
c. Define \(\overline{\mathrm{a}}\underline{s 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 40) that the student is allowed to take. The default value is 10.
d. Override the add_mark () method of the parent class. If current value of courses is \(\boldsymbol{c}\), the new add_mark method does the following:
i. If \(\boldsymbol{c}\mathbf{40}\) then new balance is updated regularly.
ii. Otherwise, if \( c40+\) 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.
2 . In a file student.py create class definitions

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!