'''lecture_31_csstudent.py Show inheritance with the CSStudent (child class) that inherits from ColbyStudent (parent class) TODO: - Discuss which methods are defined in symbol tables for ColbyStudent, CSStudent - Discuss which IVs are defined in symbol table for CSStudent object Oliver W. Layton CS 151: Computational Thinking: Visual Media Spring 2021 ''' # import lecture_31_colbystudent_template # import lecture_31_colbystudent_template as c from lecture_31_colbystudent_template import ColbyStudent # class CSStudent(lecture_31_colbystudent_template.ColbyStudent): # class CSStudent(c.ColbyStudent): class CSStudent(ColbyStudent): def __init__(self, name, year, favLang): super().__init__(name=name, year=year) self.favLang = favLang def getFavLang(self): return self.favLang def setFavLang(self, lang): self.favLang = lang def printGrades(self): '''Prints a CSStudent's grade on a 30 point scale AND on a 100 point scale''' # Print on 30 point scale # self.grades grades30 = [] grades = self.getGrades() for grade in grades: grades30.append(30*grade/100) print('Grades on a 30 point scale:') print(grades30) # Print on 100 point scale # Call parent version of printGrades print('Grades on a 100 point scale:') super().printGrades() if __name__ == '__main__': # colbyStu = ColbyStudent('Jane', 2022) csStu = CSStudent('Jim', 2024, 'Python') # print('CS Student fav language:', csStu.getFavLang()) # print('Colby Student fav language:', colbyStu.getFavLang()) csStu.addGrade(80) csStu.addGrade(90) csStu.addGrade(100) # print('Grades:') csStu.printGrades()