It's a Python question.

Asked 2 years ago, Updated 2 years ago, 21 views

A natural number n representing the number of students is input, and each student's name is Key and a list of Korean, English, and math scores is stored as Value. Print the name of the student with the highest average of all students and their average score. (The average score is only output to the second decimal place.) (If there are students with the same average score, print out the students stored further in the dictionary.)

n = int(input())

dic = {}
p = []

for i in range(n) :
    s = []
    key = input()
    k = int(input())
    e = int(input())
    m = int(input())
    s.append(k)
    s.append(e)
    s.append(m)
    dic[key] = s
    avg = sum(s) / 3
    p.append(avg)

for i in dic :
    for j in dic :
        if dic[i] < dic[j] :
            max_avg = j

print("Top :", max_avg)
print("avg : %.2f" % max(p))

I don't know what's wrong...

python

2022-09-22 16:51

1 Answers

if dic[i] < dic[j] :

In the section, we are not comparing the average score.


2022-09-22 16:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.