【百度领航团/飞桨/AI Studio】Python 学习笔记 —— 心得&总结

参与初心

快速掌握python基础内容并并运用到实战中

参与过程

每天晚上7:30观看两小时直播并且第二天看加速回放并完成作业

参与结果

完成每次作业并获得较好成绩,希望如愿得到证书

大作业验收

作业一知识点:打开文件,类的属性和函数、列表等

# 请在此处完成代码
class Student():
    def __init__(self, name, dob, age, gender, score):
        self.name = name
        self.dob = dob
        self.age = age
        self.gender = gender
        self.score = score
    def name(self):
        return self.name
    def dob(self):
        return self.dob
    def age(self):
        return self.age
    def gender(self):
        return self.gender    def top3(self):
        newlist = []
        for t in self.score:
            t = int(t)
            if t < 0 :
                t = -t
            newlist.append(t)
        return sorted(newlist)[::-1][:3]
def printf(textname):
    txtlist = opentext(textname)
    name = txtlist.pop(0)
    dob = txtlist.pop(0)
    age = txtlist.pop(0)
    gender = txtlist.pop(0)
    student = Student(name, dob, age, gender, txtlist)
    # print(student.name)a
    print(f'姓名:{student.name} 生日:{student.dob} 年龄:{student.age} 性别:{student.gender} 分数:{student.top3()}')
printf('work/stu1.txt')
printf('work/stu2.txt')
printf('work/stu3.txt')
printf('work/stu4.txt')

作业二知识点:作业一基础上加上类的继承与子父类等

# 请在此处完成代码
class Spostudent(Student):
    def __init__(self, name, dob, age, gender, score, spe):
        Student.__init__(self, name, dob, age, gender, score)
        self.spe = spe
    def spe(self):
        return self.spe
class Artstudent(Student):
    def __init__(self,  name, dob, age, gender, score):
        Student.__init__(self, name, dob, age, gender, score)    
    def top3(self):
        newlist = []
        for t in self.score:
            t = int(t)
            if t < 0 :
                t = -t
            newlist.append(t)
        return sorted(newlist)[0:3]
def printf(text,a):
    txtlist = opentext(text)
    name = txtlist.pop(0)
    dob = txtlist.pop(0)
    age = txtlist.pop(0)
    gender = txtlist.pop(0)
    spe = txtlist.pop(0)
    spostudent = Spostudent(name, dob, age, gender, txtlist, spe)
    artstudent = Artstudent(name, dob, age, gender, txtlist)
    if a == 0:
        a = spostudent.top3()
    else:
        a = artstudent.top3()
    print(f'姓名:{spostudent.name} 生日:{spostudent.dob} 年龄:{spostudent.age} 性别:{spostudent.gender} 分数:{a} 特长分:{spostudent.spe}')       
printf('work/stu5.txt', 1)
{
     spostudent.gender} 分数:{
     a} 特长分:{
     spostudent.spe}')        
printf('work/stu5.txt', 1)
printf('work/stu6.txt', 0)

你可能感兴趣的:(python)