实验五

------------恢复内容开始------------

# encoding=utf-8
# 定义一个类StudentDoc用于学生档案管理。要求:
# 数据(属性)包括:学号、姓名、专业、python课程分数
# 操作(方法)包括:打印学生信息、返回课程分数、修改课程分数
class StudentDoc:
    def __init__(self, Student_id, name, major, python_score):
        self.Student_id = Student_id
        self.name = name
        self.major = major
        self.python_score = python_score

    def Modify_the_scores(self, score):
        self.python_score = score

    def print_inf(self):
        # 打印学生信息
        print({'学号:{},姓名:{},专业:{},python课程分数{}'.format(self.Student_id,
                                                       self.name, self.major, self.python_score)})

 

 

# encoding=utf-8
import student

s1 = student.StudentDoc(11, 'mike', '应气', '99')
s2 = student.StudentDoc(11, 'jick', '应气', '50')
# 打印学生信息
s1.print_inf()
s2.print_inf()
# 修改mike课程分数
s1.Modify_the_scores(100)
# 打印Mike课程分数
print('Mike的分数:',s1.python_score)


 

 

  

  

------------恢复内容结束------------

posted @ 2021-05-29 10:54  kepler੭  阅读(52)  评论(1)    收藏  举报