Question

In: Computer Science

Assume there is a variable, nobel _peace _prizes, that is contains a dictionary that maps year's...

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

Solutions

Expert Solution

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:


Related Solutions

Short Python 3 questions a. Create a dictionary that maps the first n counting numbers to...
Short Python 3 questions a. Create a dictionary that maps the first n counting numbers to their squares. Assign the dictionary to the variable squares b. Given the list value_list, assign the number of nonduplicate values to the variable distinct_values
1.Suppose a dictionary Groceries maps items to quantities.     Write a python to print the names...
1.Suppose a dictionary Groceries maps items to quantities.     Write a python to print the names of the grocery items whose quantity exceeds 400.     For example, if groceries = {‘cake mixes’: 430, ‘cheese’:312, ‘Orange’:525, ‘candy bars’: 217}         The output will be                                 Cake mixes                                 Orange 2. which Python string method would be the best choice to print the number of time “the” occurs in a sentence entered by the user? Provide a one word answer. Just...
. Assume that a double variable named alpha contains the value of an angle in radians....
. Assume that a double variable named alpha contains the value of an angle in radians. Compose a C++ statement that will display the sine of the angle so that it occupies 12 positions on the screen and displays 3 digits after the decimal point.
The groups_per_user function receives a dictionary, which contains group names with the list of users.
The groups_per_user function receives a dictionary, which contains group names with the list of users. Users can belong to multiple groups. Fill in the blanks to return a dictionary with the users as keys and a list of their groups as values.def groups_per_user(group_dictionary):   user_groups = {}   # Go through group_dictionary   for ___:       # Now go through the users in the group       for ___:           # Now add the group to the the list of# groups for this...
Use this constant dictionary as a global variable: tile_dict = { 'A': 1, 'B': 3, 'C':...
Use this constant dictionary as a global variable: tile_dict = { 'A': 1, 'B': 3, 'C': 3, 'D': 2, 'E': 1, 'F': 4, 'G': 2, 'H': 4, 'I': 1, 'J': 8, 'K': 5, 'L': 1, 'M': 3, 'N': 1, 'O': 1, 'P': 3, 'Q': 10, 'R': 1, 'S': 1, 'T': 1, 'U': 1, 'V': 4, 'W': 4, 'X': 8, 'Y': 4, 'Z': 10 } Implement function scrabblePoints(word) that returns the calculated points for the word based on the tile_dict above....
Use this constant dictionary as a global variable: tile_dict = { 'A': 1, 'B': 3, 'C':...
Use this constant dictionary as a global variable: tile_dict = { 'A': 1, 'B': 3, 'C': 3, 'D': 2, 'E': 1, 'F': 4, 'G': 2, 'H': 4, 'I': 1, 'J': 8, 'K': 5, 'L': 1, 'M': 3, 'N': 1, 'O': 1, 'P': 3, 'Q': 10, 'R': 1, 'S': 1, 'T': 1, 'U': 1, 'V': 4, 'W': 4, 'X': 8, 'Y': 4, 'Z': 10 } Implement function scrabblePoints(word) that returns the calculated points for the word based on the tile_dict above....
Use this constant dictionary as a global variable: tile_dict = { 'A': 1, 'B': 3, 'C':...
Use this constant dictionary as a global variable: tile_dict = { 'A': 1, 'B': 3, 'C': 3, 'D': 2, 'E': 1, 'F': 4, 'G': 2, 'H': 4, 'I': 1, 'J': 8, 'K': 5, 'L': 1, 'M': 3, 'N': 1, 'O': 1, 'P': 3, 'Q': 10, 'R': 1, 'S': 1, 'T': 1, 'U': 1, 'V': 4, 'W': 4, 'X': 8, 'Y': 4, 'Z': 10 } Implement function scrabblePoints(word) that returns the calculated points for the word based on the tile_dict above....
Python HW with Jupyter Notebook Declare a variable named DATA as a dictionary object. Assign the...
Python HW with Jupyter Notebook Declare a variable named DATA as a dictionary object. Assign the set of key/value pairs shown below. Create a function named iter_dict_funky_sum() that takes one dictionary argument.    Declare a running total integer variable. Extract the key/value pairs from DATA simultaneously in a loop. Do this with just one for loop and no additional forms of looping. Assign and append the product of the value minus the key to the running total variable. Return the funky...
C++ 3a)Assume you have an integer pointer variable named intpoint2. It contains the address 1e6f24. You...
C++ 3a)Assume you have an integer pointer variable named intpoint2. It contains the address 1e6f24. You execute intpoint2++. What does intpoint2 now contain? a)1e6f24 b)1e6f25 c)1e6f28 d)1e6f2c 3b)You have an array of integers: int myints[10]; and the address of the first integer is be4350. What is the address of myints[1]? myints[2]?You have an array of integers: int myints[10]; and the address of the first integer is be4350. What is the address of myints[1]? myints[2]? a)Both are b34350 b)be4350 and b34354...
2. Assume that the Lempel-Ziv (Dictionary) is applied to a source which emits {1,2,3}. The source...
2. Assume that the Lempel-Ziv (Dictionary) is applied to a source which emits {1,2,3}. The source output is given by 1233221233112233344. (a) Please apply the Lempel-Ziv coding, show how you applied? (b) Please write down the transmission sequence? (c) Please explain how you decode the transmission sequence that you have in the pre- vious part?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT