+ 6

Is there any other way to solve this without calling "mean()" function twice in 8th no line?

https://code.sololearn.com/c6Mj2rTAc9wM/?ref=app

27th Jul 2018, 8:29 PM
Sayan Kundu
8 odpowiedzi
+ 2
You can calculate all the means first: means = [(name, mean(scores)) for (name, scores) in input.items()] and then get the biggest mean with the max function: maximum = max(means, key=lambda x: x[1])
27th Jul 2018, 11:27 PM
Schindlabua
Schindlabua - avatar
28th Jul 2018, 1:21 AM
Oma Falk
Oma Falk - avatar
+ 4
Sayan Kundu no prob! all students with highscore are printed
29th Jul 2018, 11:47 AM
Oma Falk
Oma Falk - avatar
+ 2
This is the best I can do, though it's still probably not quite what you wanted :( https://code.sololearn.com/cKC3Lr8XfKFf/?ref=app Edited code to my actual attempt. For some reason, my saved code was identical to yours Sayan Kundu !
28th Jul 2018, 10:14 AM
Russ
Russ - avatar
+ 1
Schindlabua Oma Falk But, in the input dictionary more than one student have highest score. So the output could be a list of multiple names.
28th Jul 2018, 3:11 AM
Sayan Kundu
+ 1
I can construe this into a oneliner but it is just bad practice. https://code.sololearn.com/cNmGjIS5YaHN/?ref=app
28th Jul 2018, 6:18 AM
Louis
Louis - avatar
+ 1
New attempt - one liner and one usage of "mean()". https://code.sololearn.com/c5z0wDpbHrYW/?ref=app It's just that using 'eval()' is generally considered bad practice.
28th Jul 2018, 6:25 PM
Russ
Russ - avatar
0
what does return do again?
1st Aug 2018, 7:04 PM
jam