Prof. Abhiram has taken an exam of his students. He has stored the marks of students in a dictionary where keys are the student’s name and values in the dictionary are student marks. Now he wants to know the name of students obtained minimum and maximum marks from this dictionary. You need to write a python function Find_Min_Max(A) which takes a dictionary as input parameter and return the name of student pair having minimum and maximum marks in the class as shown in the example.
Example-1
Example-2
Input:
{'Theodore': 19, 'Roxanne': 22, 'Mathew': 21, 'Betty': 20}
Output:
('Theodore', 'Roxanne')
Input:
{'Roudy': 9, 'Alexa': 2, 'Prett': 18, 'Holmes': 22}
Output:
('Alexa', 'Holmes')
def Find_Min_Max(A):
names = sorted(A, key=A.get)
return names[0], names[-1]
studentMarks = {'Theodore': 19, 'Roxanne': 22, 'Mathew': 21, 'Betty': 20}
print(Find_Min_Max(studentMarks))
studentMarks = {'Roudy': 9, 'Alexa': 2, 'Prett': 18, 'Holmes': 22}
print(Find_Min_Max(studentMarks))
Comments
Leave a comment