题解 | #班级管理#

班级管理

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

class Student():
    def __init__(self,name,id,score,rate) :
        super().__init__()
        self.name=name
        self.id=id
        self.score=score
        self.rate=rate
    def output(self):
        print(f"{self.name}'s student number is {self.id}, and his grade is {self.score}. He submitted {len(self.rate)} assignments, each with a grade of {' '.join(self.rate)}")
name=input()
id=input()
score=int(input())
rate=input().split(' ')
student=Student(name,id,score,rate)
student.output()

将列表中的元素提取出来可用join方法

全部评论

相关推荐

03-05 16:22
已编辑
西安邮电大学 Web前端
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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