Question: PYTHON Exercises 1: Each student at PSUT(University Name) has an id, a name, a GPA, and a major. A student can be a bachelors student

PYTHON

Exercises 1: Each student at PSUT(University Name) has an id, a name, a GPA, and a major. A student can be a bachelors student or a masters student. Bachelor students are required to do a graduation project and training at some company. Master students are required to do a thesis. The Bachelor student rating is different from the Master student rating. Given the following student class:

class Student : def __init___(self, i=0, g=0, n="", m=""):

self.id=i

self.gpa=g

self.name = n

self.major=m

def setID (self,i) :

self.id=i

def setGPA(self,g):

self.gpa=g

def setName(self,n):

self.name = n

def setMajor(self, m):

self.major=m

def getMajor(self):

self.major

def getRating(self):

print(end="") #just do nothing

def isBachelor(self):

print(end="") #just do nothing

def printInfo(self):

print(end="") #just do nothing

def getGPA(self):

return self.gpa

A: Define a new class called BachelorStudent. This class should:

1. Inherit (derive) from the Student class and include two new string member variables (project_title, training_company).

2. Define a constructor to initialize all member variables (id, GPA, name, major, project_title, training_company).

3. Override the getRating method such that it returns Excellent for GPA >=84, Very good for [76 to =86, Very good for [76 to 70 ) and Fail otherwise.

4. Override isBachelor to return false.

5. Override printInfo to print student id, student name, GPA, and rating.

B: Define a new class called MasterStudent. This class should:

1. Inherit (derive) from the Student class and include one new string member variable (thesis).

2. Define a constructor to initialize all member variables (id, GPA, name, major, thesis).

3. Override getRating method such that it returns Excellent for GPA >=86, Very good for [76 to 70 ) and Fail otherwise.

4. Override isBachelor to return false. 5. Override printInfo to print student id, student name, GPA, and rating.

C: write a driver method to test your classes, such that:

1. Create a list to track the students of both types.

2. Read the information of 10 students and store them inside the list defined in the previous step. The user will be asked to specify the type of student first (Master, or Bachelor), and then input data according to the type of student.

3. Print all student names whose ranking is Excellent regardless of their type (Master or Bachelor).

4. Print all Bachelor student names whose Major is "CS".

Exercises 2:

1. Write a simple python code to create a NumPy array of the small letters, a-z.

2. What happens if you pass no arguments to the np.array()? Write a short example to explain your answer.

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 Databases Questions!