Discuss / Python / 打卡

打卡

Topic source

邹lh

#1 Created at ... [Delete] [Delete and Lock User]
class Student(object):
    def __init__(self, name, score):
        self.name = name
        self.score = score
    def get_grade(self):
            if self.score >100 or self.score<0:
                raise ValueError('wrong input')
            if self.score >= 60 and self.score<=79:
                return 'B'
            if self.score >= 80 and self.score<=100:
                return 'A'
            else:
                return 'C'

  • 1

Reply