对于作文课,我需要存储成绩的属性应该是公开的,并且始终在 0.0 和 4.0 之间。我在想的是 set_grade(self,grade) 但是你如何实现一个 if 语句来确保它返回一个介于 4.0 之间的数字 0.0
class Assessment:
grade = 0
def get_grade(self):
return self.grade
"""This operation is creating a concrete subclass of Assessment"""
class Essay (Assessment):
"""This operation is getting the grade the grade for the Essay class which will return a grade"""
def get_grade(self):
return self.grade
"""This operation is creating a TeamProject Class with an individual score and a team score grade"""
class Teamproject(Assessment):
ind_sc = 0
ts_sc = 0
"""This operation is getting the grade to individual score and team score and returning the average"""
def get_grade(self):
return (self.ind_sc +self.ts_sc) / 2