怎样把这一串代码改成class形式
ef student_score(name, chinese, math, english, science):
return {"name": name, "chinese": chinese, "math": math, "english": english, "science": science}
def score_sum(student):
return student["chinese"] + student["math"] + student["english"] + student["science"]
def score_avg(student):
return score_sum(student)/4
def score_print(student):
return print(student["name"], score_sum(student), score_avg(student), sep="\t")
# 女学生名单.
students_women = [
student_score("PING", 64, 88, 92, 92 )
student_score("BASMA", 64, 88, 92, 92 ),
student_score("MEIJUN", 64, 88, 92, 92 ),
student_score("WENQI", 64, 88, 92, 92 ),
student_score("ZHILING", 64, 88, 92, 92 ),
student_score("JINHUA", 64, 88, 92, 92 ),
student_score("DO", 64, 88, 92, 92 )
]
# 男学生名单.
students_men = [
student_score("HAIMING", 64, 88, 92, 92 ),
student_score("ZHENG", 64, 88, 92, 92 ),
student_score("KONG", 64, 88, 92, 92 )
]
# 重复女学生名单.
print("女学生分数")
print("名字", "总分", "平均分", sep="\t")
for student in students_women:
score_print(student)
# 重复男学生名单.
print("\n男学生分手")
print("名字", "总分", "平均分", sep="\t")
for student in students_men:
score_print(student)