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 += 1
  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 >= score :
  19. avreage_count += avreage_score
  20.  
  21. # 打印大于等于平均成绩的个数
  22. print(f'大于等于平均成绩的个数为:{avreage_count } ')
  23.  
Success #stdin #stdout 0.07s 8008KB
stdin
Standard input is empty
stdout
总成绩为:10			, 平均成绩为:1.0				
大于等于平均成绩的个数为:10.0