Discuss / Python / 作业

作业

Topic source

极大似然

#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 not in range(101):
            raise ValueError('invalid score')
        if self.score >= 80:
            return 'A'
        if self.score >= 60:
            return 'B'
        return 'C'

  • 1

Reply