Python, small case

In a competition, a total of 5 judges gave scores to the players. When calculating the player's score, remove the highest score and the lowest score, and then calculate the average value. This value is the player's score. The specific implementation is shown in the example.

score=[]
for i in range(1,6):
    num=float(input('%d号评委打分: '%i))
    score.append(num)
min =min(score)  #获取最低分数
max =max(score)  #获取最高分数
score.remove(min) #去除最低分数
score.remove(max) #去掉最高分数
ave =sum(score)/len(score) #求平均值
print('选手最终的分数%.2f'%ave)

operation result:
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_43398418/article/details/110245783