我有一个Attribute类,其中包含要向平均10以上的学生展示的学生列表,但是如何在属性类上调用方法?
class Scores:
students =[]
def __init__(self, code, listScore=[]):
self.Score = listScore
self.code=code
Scores.students.append(self)
def add_Score(self):
for i in range(3):
d = input(f"Enter number {i+1} : ")
self.Score.append(d)
def pass__(self):
for grade in self.Score:
if int(grade) < 10:
return False
return True
def Passed(self):
for student in Scores.students:
if self.pass__():
return (f" Passed : {self.code}")
You should just be able to assign to
students
, noScores
needed. For more info, see: https://www.toptal.com/python/python-class-attributes-an-overly-thorough-guide