Jan-20-2026, 05:36 AM
(This post was last modified: Feb-02-2026, 02:48 AM by jadongreen.)
Hi everyone, I’m Jason and this is a homework problem my teacher gave me. I’m struggling with it, can someone help? Geometry Dash
Write a Python program that:
1. Reads a text file named
3. Prints all student names whose score is above the average.
4. Sorts the output by score descending, and if scores are tied, by name ascending.
I tried reading the file and computing the average, but I’m not sure how to sort and filter properly.
Thanks!
Link Removed
Write a Python program that:
1. Reads a text file named
grades.txt containing student names and their numeric scores (0–100), one per line, like:Alice 92 Bob 78 Charlie 85 David 78 Emma 922. Calculates the average score.
3. Prints all student names whose score is above the average.
4. Sorts the output by score descending, and if scores are tied, by name ascending.
I tried reading the file and computing the average, but I’m not sure how to sort and filter properly.
def read_scores(filename):
with open(filename) as f:
lines = f.readlines()
scores = []
for line in lines:
name, score = line.split()
scores.append((name, int(score)))
return scores
data = read_scores('grades.txt')
# … I’m stuck here …
print(data)Can someone show how to finish this and output the correct result?Thanks!
Link Removed
Gribouillis write Jan-20-2026, 06:33 AM:
Clickbait link removed. Please read What to NOT include in a post
Clickbait link removed. Please read What to NOT include in a post
