scores = [] for i in range(10): print("请输入第{}位同学的成绩单:".format(i+1)) grade = [] for j in range(3): grade.append(float(input("请输入第{}门课程的成绩:".format(j+1)))) scores.append(grade) total_scores = [] for i in range(10): total_score = sum(scores[i]) total_scores.append(total_score) print("第{}位同学的总分为:{}".format(i+1, total_score)) sorted_scores = sorted(total_scores, reverse=True) print("按总分从高到低排序的成绩单为:") for score in sorted_scores: index = total_scores.index(score) print("第{}位同学的总分为:{}".format(index+1, score)) avg_scores = [] for i in range(3): avg_score = 0 for j in range(10): avg_score += scores[j][i] avg_score /= 10 avg_scores.append(avg_score) print("三门课程的平均成绩分别为:第{}门课程的平均成绩为{}".format(i+1, avg_score))
时间: 2023-05-31 13:06:58 浏览: 138
There seems to be some formatting issues in the code provided. Here's a corrected version:
scores = []
for i in range(10):
print("请输入第{}位同学的成绩单:".format(i+1))
grade = []
for j in range(3):
grade.append(float(input("请输入第{}门课程的成绩:".format(j+1))))
scores.append(grade)
total_scores = []
for i in range(10):
total_score = sum(scores[i])
total_scores.append(total_score)
print("第{}位同学的总分为:{}".format(i+1, total_score))
sorted_scores = sorted(total_scores, reverse=True)
print("按总分从高到低排序的成绩单为:")
for score in sorted_scores:
index = total_scores.index(score)
print("第{}位同学的总分为:{}".format(index+1, score))
avg_scores = []
for i in range(3):
avg_score = 0
for j in range(10):
avg_score += scores[j][i]
avg_score /= 10
avg_scores.append(avg_score)
print("第{}门课程的平均成绩为{}".format(i+1, avg_score))
Note: I made some assumptions about what the code should do based on the given prompt, as there were some missing details (e.g. what to do with the average scores).
阅读全文