程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Didnt sister Lang give enough marks? Simulate judges scoring with a few lines of Python code

編輯:Python

Hello, everyone ~ I'm a panda
Everyone has seen the game , Are you always looking forward to the results of the competition . In particular, sister Lang can't stop scoring …

Use today Python To simulate the judges' scoring , This case is very short and simple , It is very suitable for novices to practice with Xiaobai .

In a top ten singer competition ,7 Judges rated the singers , When calculating the total score , You need to get rid of one of the highest scores , Remove a minimum score , Then output the total score and average score . Asked to help the jury write the singer scoring program , Input 7 The rating of the judges , Output total score and average score . The final effect is as shown in the figure .


The sample code is as follows :


if __name__ == '__main__':
print("\033[1;35m Top ten singers scoring program ")
print("===================================\033[0m")
score_str = input(" Please enter 7 Scores of referees , Use English commas to separate fractions : \n")
# ['78.5', '67.2', '89', '98.7', '88', '99', '77']
temp_score_list = score_str.split(",")
# [78.5, 67.2, 89.0, 98.7, 88.0, 99.0, 77.0]
score_list = list(map(float, temp_score_list))
max_score = max(score_list)
min_score = min(score_list)
print(f" Remove a minimum score : {min_score}")
score_list.remove(min_score)
print(f" Remove one of the highest scores : {max_score}")
score_list.remove(max_score)
print(f" The effective score of the singer is : {score_list}")
print(" The singer scored : %.1f" % (sum(score_list) / len(score_list)))

Is it really short , All at once , If this article helps you , Please don't be stingy with your praise , thank you !

I'm a panda , Let's see... In our next article


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved