M
M
Mark2021-10-27 20:17:02
Python
Mark, 2021-10-27 20:17:02

Python task using dictionary?

Create a dictionary of prospective student grades (Key - student's FI, value - list of student grades). Find the most successful and the most lagging behind in terms of average score.
the question is how to get the minimum and maximum average score from the dictionary

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
antares4045, 2021-10-27
@incandescent99

question from the series what color to choose for wallpaper: now get it from a person according to the method.
I'm lazy today

marks = {
    'a' : [1,2,3],
    'b' : [0,1,2],
    'c' : [5,6,6],
    'd' : [4,4,4]
}

def mean(lst):
    return sum(lst) / len(lst)

sortedIds = sorted(marks.keys(), key=lambda studentId: mean(marks[studentId]))

print('лучший:', sortedIds[-1])
print('худший:', sortedIds[0])

Conclusion:
best: c
worst: b

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question