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

Python Develop two subclasses Instructor and Student as subclasses of the class

ID: 3662233 • Letter: P

Question

Python

Develop two subclasses Instructor and Student as subclasses of the class Person.

The class Instructor defines two methods:

An overloaded constructor __init__() that takes the instructor's degree in addition to their name and birth year. This constructor has three parameters. It should set the degree of the instructor to the specified parameter but should call the constructor for the Person class to set the name and birth year of the instructor. Solutions that duplicate the code found in the constructor of the Person class will not earn full credit. Default values of 'unknown' should be used for the name and degree when those parameters aren't provided. A default year of 1985 should be used for the birth year when it is not provided. Make sure to set the defaults in the header for the function as demonstrated in class.

degree() which returns the degree of the instructor.

The Student class defines two methods:

An overloaded constructor __init__() that takes the student's major in addition to their name and birth year. This constructor has three parameters. It should set the major of the student to the specified parameter but should call the constructor for the Person class to set the name and birth year of the student. Solutions that duplicate the code found in the constructor of the Person class will not earn full credit. Default values of 'unknown' should be used for the name and major when those parameters aren't provided. A default year of 1997should be used for the birth year when it is not provided. Make sure to set the defaults in the header for the function as demonstrated in class.

major() which returns the major of the student.

The following shows how the Instructor and Student classes and methods could be used:

Explanation / Answer

# cook your code here
import os,math

#this class can save it as Instrurctor.py

class Instructor():

#declaring 3 variables
def __init__(self,name,degree,birthyear):
self.name= self.name;
self.degree = self.degree;
self.birthyear = self.birthyear;
  
#for degree print
def degree(self):
print self.degree

# for age print   
def print(self):
age = 2015 -self.birthyear
print self.name,"is" ,age,"years old"
  
#this class can save it as student.py

class student():
# 3 variables defined
def __init__(self,name,birthyear,çlassstudied):
self.name = self.name
self.birthyear = self.birthyear
self.classstudied = self.classstudied
  
# for age print
def print(self):
age = 2015 -self.birthyear
print self.name,"is" ,age,"years old"

#which class studied display
def major(self):
   print self.classstudied
  
  
class Person():
#2 variables only
def __init__(self,name,birthyear):
self.name = name
self.birthyear = birtyear
  
#here we can create objects for above classes

p1 = Instructor('settlde',1970,'Ph.D')

d1 = p1.Degree()

print (p1)

p1

p2 = student("elam",1995,'computer science')

p2.major()

and so on as per your requirement.