class Student(object): """docstring for student""" def init(self, name,score): super(Student, self).init() self.name = name self.score = score
def printScore(self): print('name:%s score:%s' %(self.name,self.score)) def get_grade(self): if self.score >= 90: print('The score is: 优秀') elif self.score >= 80: print('The score is: 良好') elif self.score >= 70: print('The score is: 中等') elif self.score >= 60: print('The score is: 及格') else: print('The score is: 差')
stu1 = Student('yangsenkai',70) stu1.printScore() stu1.get_grade() Student.printScore(stu1)
Sign in to make a reply
Young先森森
class Student(object): """docstring for student""" def init(self, name,score): super(Student, self).init() self.name = name self.score = score
stu1 = Student('yangsenkai',70) stu1.printScore() stu1.get_grade() Student.printScore(stu1)