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