Answer to Question #298864 in Python for Michael

Question #298864

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')



1
Expert's answer
2022-02-17T05:21:03-0500
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))

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