對於論文類我需要存儲等級的屬性應該是公開的,並且始終在0.0到4.0之間。我在想什麼是set_grade(個體經營,等級),但你怎麼實現if語句,以確保其返回4.0屬性Python添加設置值
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
應當注意的是,你在壓痕徹底打破,你的文檔字符串是在錯誤的地方。 –
doc字符串像? @LennartRegebro – user2267830
http://www.python.org/dev/peps/pep-0257/ http://www.pythonforbeginners.com/basics/python-docstrings/ –