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())
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,python,self,StudentDoc,score,._,s1 来源: https://www.cnblogs.com/wenjiahui/p/14811237.html