Python Assignment 2
Python Assignment 2
import operator
thisdict = { 'a': 91, 'b': 74, 'c': 11, 'd': 64, 'e': 0, 'f': 38, 'g': 9}
print("The original dictionary:", thisdict)
sorteddict = sorted(thisdict.items(), key=operator.itemgetter(1))
print("Ascending order:",sorteddict)
sorteddict = sorted(thisdict.items(), key=operator.itemgetter(1), reverse=True)
print("Descending order:",sorteddict)
OUTPUT:
3. Write a Python program to count number of items in a dictionary value
that is a list.
OUTPUT:
4. Drop empty Items from a given Dictionary
OUTPUT:
5. Write a Python program to check multiple keys exists in a dictionary.
OUTPUT:
Output on Mozilla Firefox Uncropped: