Answer to Question #297837 in Python for Soumya

Question #297837

Lowest and highest score. The teacher gave out the scores of the science quiz conducted last week and asked the ones with the lowest and highest scores to group up. Print the names of the students with minimum and maximum scores, respectively.

Note: In case of a tie, choose the name which comes first in the (dictionary order).

Input : 2

shakti 24

disha 26

output: shakti disha

input: 3

ajay 23

bijay 24

sanjay 23

output: ajay bijay


1
Expert's answer
2022-02-14T18:33:32-0500
n = int(input()) 
students = []
for _ in range(n):
    students.append(input().split())


# print the name of the student with the minimum score
print(min(students, key = lambda student: (int(student[1]), student[0]))[0], end=' ')


# print the name of the student with the maximum score
print(min(students, key = lambda student: (-int(student[1]), student[0]))[0])

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS