题解 | #班级管理#

班级管理

https://www.nowcoder.com/practice/e5539db11767449ab2fb68ed3c2446d0

定义接收数据的变量

name = input()
number = input()
score = int(input())
grade = input().split(" ")

定义Student类的业务逻辑

class Student:
    def __init__(self, name, number, score, grade):
        self.name = name
        self.number = number
        self.score = score
        self.grade = grade

    def information(self):
        print(
            "%s's student number is %s, and his grade is %s. He submitted %s assignments, each with a grade of %s"
            % (
                self.name,
                self.number,
                self.score,
                len(self.grade),
                " ".join(self.grade),
            )
        )

实例化Student类并调用information函数输出结果

student = Student(name, number, score, grade)
student.information()
全部评论

相关推荐

09-14 20:51
四川大学 Java
慢热的鲸鱼在学习:985加粗就行了,第二个项目来不及准备也没事,省的写了问你你还不会。你只需准备面试八股和项目场景,剩下的交给985。即使面不过也没事,面试经验是最重要的,你现在不缺时间
简历中的项目经历要怎么写
点赞 评论 收藏
分享
投递网易等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务