Fundamentals 3 min read

Python Program to Compute Singer Scores by Dropping Highest and Lowest Judges' Marks

This article presents a Python script that reads seven judges' scores for a singer, removes the highest and lowest marks, then calculates and displays the total and average scores, illustrating the solution with a complete code example.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Python Program to Compute Singer Scores by Dropping Highest and Lowest Judges' Marks

In a singing competition, seven judges score each performer, but the final total requires discarding the highest and lowest scores before computing the sum and average. This article provides a Python program that prompts the user to input the seven scores, processes them accordingly, and outputs the effective scores and the final average.

Example code:

if __name__ == '__main__':
    # 1. Print title and separator
    print("\033[1;35m  十佳歌手打分程序")
    print("===================================\033[0m")
    # 2. Input scores for 7 judges
    score_str = input("请输入7名裁判的打分,用英文逗号间隔分数: \n")
    # 3. Split the string into a list
    # ['78.5', '67.2', '89', '98.7', '88', '99', '77']
    temp_score_list = score_str.split(",")
    # Convert each string to a float
    # [78.5, 67.2, 89.0, 98.7, 88.0, 99.0, 77.0]
    score_list = list(map(float, temp_score_list))
    # 4. Find the highest and lowest scores
    max_score = max(score_list)
    min_score = min(score_list)
    # 5. Output results
    print(f"去掉一个最低分: {min_score}")
    score_list.remove(min_score)
    print(f"去掉一个最高分: {max_score}")
    score_list.remove(max_score)
    # Output effective scores
    print(f"该歌手的有效打分为: {score_list}")
    # Output final average (one decimal place)
    print("该歌手的得分为: %.1f" % (sum(score_list) / len(score_list)))

If you found this article helpful, please consider giving it a like. Thank you!

AlgorithmpythonprogrammingTutorialScoring
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.