In: Computer Science
Assume there is a variable, nobel _peace
_prizes,
that is contains a dictionary that maps year's to winners of the
Nobel Peace Prize 'f'or that year and assume it is up to date
through the year 2005.Write a statement that adds an entry that
maps the key 2006 to "Muhammad Yunus and Grameen Bank".
In Python programming language
Dict={} # declare a empty dictionary
nobel_peace_prizes=Dict # variable nobel_peace_prizes assigned
to dictionary
Dict[2000] = 'ABC'
Dict[2001] = 'DEF'
Dict[2002] = 'GHI'
Dict[2003] = 'JKL'
Dict[2004] = 'MNO'
Dict[2005] = 'PQR' #consider intial Dictionary contains 5 entry
print("\nInitial dictionary with 5 elements: ")
print(nobel_peace_prizes)
Dict[2006]='Muhammad Yunus and Grameen Bank' # you can
either add new entry by this method
print("\n Dictionary after adding winner to year 2006 : ")
print(nobel_peace_prizes)
Dict[2006]=input("\nEnter winner name for year 2006:",)
# OR you can either add new entry by this method
print("\nDictionary after adding winner to year 2006: ")
print(nobel_peace_prizes)
Note : Only bold statements are asked in the question. You can use any method to add new entry to dictionary
Output: