
Patrick B. answered 02/26/21
Math and computer tutor/teacher
import datetime
class Person:
def __init__ (self,firstname,lastname,dob):
self.fname = firstname
self.lname = lastname
self.dob = dob
def getFullname(self):
return str(self.fname) + " " + str(self.lname)
def getDOB(self):
return str(dob)
def getAge(self):
tokens = self.dob.split("/")
iMonth = tokens[0]
iDay = tokens[1]
iYear = tokens[2]
print("year:month:day=" + str(iYear) + ":" + str(iMonth) + ":" + str(iDay))
today = datetime.date.today()
birthdate = datetime.date(int(iYear),int(iMonth),int(iDay))
years = int(today.year) - int(birthdate.year)
if today.month < birthdate.month or (today.month == birthdate.month and today.day < birthdate.day):
years -= 1
return years
class Student(Person):
def __init__(self,firstname,lastname,dob,studentid,gradelevel):
Person.__init__(self,firstname,lastname,dob)
self.studentID = studentid
self.gradeLevel = gradelevel
self.courseMarks = { "course":"mark" }
def GetStudentID():
return studentID
def GetGradeLevel():
return gradeLevel
def addCourseMarks(self,x,y):
self.courseMarks.update({x:y})
#################################################
firstName="Patrick"
lastName="Baldwin"
dob="02/11/1968"
myTeacher = Person(firstName,lastName,dob)
print(myTeacher.getFullname())
print("dob = "+ myTeacher.getDOB())
print(myTeacher.getAge())
firstName="John"
lastName="Smith"
dob="12/01/2006"
gradeLevel="Grade 10"
studentID ="10023"
myStudent=Student(firstName,lastName,dob,studentID,gradeLevel)
print(myStudent.getFullname())
print(myStudent.getAge())
course="Math"
mark=90
myStudent.addCourseMarks(course,mark)
course="Science"
mark=88
myStudent.addCourseMarks(course,mark)
course="Social"
mark=77
myStudent.addCourseMarks(course,mark)
course="LA"
mark=98
myStudent.addCourseMarks(course,mark)
print(myStudent.courseMarks)