task5

class StudentDoc:
    def __init__(self, number, name, major, python):
        self._number = number
        self._name = name
        self._major = major
        self._python = python

    def info(self):
        print(f'学号: {self._number}, 姓名: {self._name}, 专业: {self._major}, python课程分数: {self._python}')

    def score(self):
        return self._python

    def change(self, new_score):
        self._python= new_score
        return new_score


s1 = StudentDoc(24, 'Bob', 'ecology', 87)
s1.info()
print(s1.score())
s1.change(92)
print(s1.score())

  

  task5

from student import StudentDoc

s1 = StudentDoc('12', 'Kristal', 'art', '82')
s2 = StudentDoc('48', 'sherry', 'math', '80')

s1.info()
s2.info()

s1.change(87)
s2.change(85)

print(s1.score() )
print(s2.score() )

  task5

上一篇:李宏毅机器学习-Task5


下一篇:异常检测-task5-集成方法