CBSE Class 11 Informatics Practices
Question 43 of 66
Dictionary — Question 15
Back to all questions 15
Question Write a Python program to find the highest 2 values in a dictionary.
d = {'a': 10, 'b': 30, 'c': 20, 'd': 50, 'e': 40}
s = sorted(d.values())
print("Dictionary:", d)
print("Highest 2 values are:", s[-1], s[-2])Dictionary: {'a': 10, 'b': 30, 'c': 20, 'd': 50, 'e': 40}
Highest 2 values are: 50 40