首页 > 其他 > 详细

task5

时间:2021-05-26 00:54:44      阅读:24      评论:0      收藏:0      [点我收藏+]
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

原文:https://www.cnblogs.com/wenjiahui/p/14811237.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!