Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please Help with a python script that can run the following thanks! Implement tw

ID: 3759985 • Letter: P

Question

Please Help with a python script that can run the following thanks!

Implement two subclasses of class Person described in Problem 8.24. The class Instructor supports methods:

• __init__():Constructor that takes the person’s degree in addition to name and birth year

• degree(): Returns the degree of the instructor

The class Student, also a subclass of class Person, supports:

• __init__():Constructor that takes the person’s major in addition to name and birth year

• major(): Returns the major of the student

Your implementation of the three classes should behave as shown in the next code:

>>> x = Instructor('Smith', 1963, 'PhD')

>>> x.age()

45

>>> y = Student('Jones', 1987, 'Computer Science')

>>> y.age()

21

>>> y.major()

'Computer Science'

>>> x.degree()

'PhD'

Explanation / Answer

Program code:

class Person:
    def __init__(self, name, birthyear):
        self.__name=name
        self.__birthyear=birthyear
   

class Instructor(Person):
    def __init__(self, name, birthyear, degree):
        self.super = Person(name, birthyear)
        self.degree = degree
    def getdegree(self):
        return self.degree
    def getage(self):
        now = 2015
        age=(now-super.birthyear)
        return age


class Student(Person):
    def __init__(self, name, birthyear, major):
        self.super = Person(name, birthyear)
        self.major = major
    def getmajor(self):
        return self.major
    def getbirthyear(self):
        return self.birthyear
    def getage(self):
        now = 2015
        age=(now-super.birthyear)
        return age

sample output: