Here is an example of a Python program to find the minimum and maximum value in a dictionary and print by sorting in ascending order.
Python Program to Find Min and Max Value in a Dictionary
prices = { 'ABCL': 42.23, 'AENO': 632.58, 'IBM': 235.25, 'HPQ': 32.21, 'FB': 13.35 } # Find min and max price min_price = min(zip(prices.values(), prices.keys())) max_price = max(zip(prices.values(), prices.keys())) print('min price:', min_price) print('max price:', max_price) print('sorted prices:') prices_sorted = sorted(zip(prices.values(), prices.keys())) for price, name in prices_sorted: print(' ', name, price)
Output:
min price: (13.35, 'FB') max price: (632.58, 'AENO') sorted prices: FB 13.35 HPQ 32.21 ABCL 42.23 IBM 235.25 AENO 632.58