python 从键盘输入多个学生的高等数学成绩存于列表中当输入为空时表示输入结束此时输出学生人数、最高分、最低分、平均分。
scores = [] while True: score = input("请输入学生成绩:") if score == "": break scores.append(float(score))
num = len(scores) if num == 0: print("没有输入任何成绩。") else: max_score = max(scores) min_score = min(scores) avg_score = sum(scores) / num print("学生人数:", num) print("最高分:", max_score) print("最低分:", min_score) print("平均分:", avg_score)
原文地址: http://www.cveoy.top/t/topic/gPEC 著作权归作者所有。请勿转载和采集!