fork download
  1. # 定义学生成绩列表
  2. student_score = [78, 65, 92, 78, 90, 45, 83, 57, 96, 56]
  3. # 定义总成绩变量
  4. sum_score = 0
  5. # 遍历 求总成绩
  6. for score in student_score :
  7. # 累加成绩
  8. sum_score += score
  9. # 定义平均成绩变量
  10. avreage_score = sum_score / len(student_score)
  11. # 打印总成绩和平均成绩
  12. print(f'总成绩为: {sum_score} , 平均成绩为: {avreage_score} ')
  13. # 定义大于等于平均成绩的个数的变量
  14. avreage_count = 0
  15. # 求个数 遍历
  16. for score in student_score :
  17. # 验证
  18. if score >= avreage_score :
  19. avreage_count += 1
  20.  
  21. # 打印大于等于平均成绩的个数
  22. print(f'大于等于平均成绩的个数为: {avreage_count} ')
Success #stdin #stdout 0.12s 14176KB
stdin
Standard input is empty
stdout
总成绩为:	740		, 平均成绩为:	74.0		
大于等于平均成绩的个数为:	6