Python Example – Write a Python program to get the maximum and minimum value in a dictionary
(Python Example for Citizen Data Scientist & Business Analyst) Write a Python program to get the maximum and minimum value in a dictionary. Sample Solution: Python Code: my_dict = {‘x’:500, ‘y’:5874, ‘z’: 560} key_max = max(my_dict.keys(), key=(lambda k: my_dict[k])) key_min = min(my_dict.keys(), key=(lambda k: my_dict[k])) print(‘Maximum Value: ‘,my_dict[key_max]) print(‘Minimum Value: ‘,my_dict[key_min]) Sample Output: … Continue reading Python Example – Write a Python program to get the maximum and minimum value in a dictionary
Copy and paste this URL into your WordPress site to embed
Copy and paste this code into your site to embed