Python 随机评分计算:去除最高最低分后的平均分
import random
生成10位评委的评分
scores = [] for i in range(10): score = random.randint(1, 100) scores.append(score)
去掉最低分和最高分
scores.remove(min(scores)) scores.remove(max(scores))
计算平均分
average_score = sum(scores) / len(scores)
print('评委的评分为:', scores) print('去掉一个最低分和一个最高分后的总评分为:', sum(scores)) print('去掉一个最低分和一个最高分后的平均分为:', average_score)
原文地址: https://www.cveoy.top/t/topic/nwkB 著作权归作者所有。请勿转载和采集!