题解 | #班级管理#
班级管理
http://www.nowcoder.com/practice/e5539db11767449ab2fb68ed3c2446d0
创建Student类并进行初始化与信息打印
class Student(object):
def __init__(self, name, number, score, grade):
self.name = name
self.number = number
self.score = score
self.grade = grade
def student_information(self):
return "%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))
进行接收信息处理与实例化
name = input()
number = input()
score = input()
grade = list(input().split(' '))
student = Student(name, number, score, grade)
print(student.student_information())