如何设计一个一维数组并求出平均分、最高分和最低分,在主函数中显示平均分、最高分和最低分?

设计一个一维数组存放10个学生成绩求出平均分、最高分和最低分,在主函数中显示平均分、最高分和最低分?

运行结果示例:
Input 10 scores:
88 90 88 70 40 80 92 90 92 95
AverScore = 82.5
MaxScore = 95.0
MinScore = 40.0

输入提示信息:"Input 10 scores:\n"
输入格式:"%f"
输出格式:"AverScore = %.1f\nMaxScore = %.1f\nMinScore = %.1f\n"

梦里花落0921
浏览 118回答 1
1回答

qq_遁去的一_1

scores = []for i in range(10):score = float(input("Input score %d: " % (i+1)))scores.append(score)avg_score = sum(scores) / 10max_score = max(scores)min_score = min(scores)print("AverScore = %.1f\nMaxScore = %.1f\nMinScore = %.1f\n" % (avg_score, max_score, min_score))Input 10 scores:88 90 88 70 40 80 92 90 92 95AverScore = 82.5MaxScore = 95.0MinScore = 40.0 
打开App,查看更多内容
随时随地看视频慕课网APP