Question: Sample output ('a' 100,:300, ' 200, 'd':400) Exercise 4 Write a function called merge2 that takes two dictionaries as parameters. These in these input lists,

 Sample output ('a' 100,:300, ' 200, 'd':400) Exercise 4 Write a

function called merge2 that takes two dictionaries as parameters. These in these

input lists, the values will always be integers. This function will create

a new dictionary that contains everything from the two input dictionaries and

return it. If the input lists have common keys, the merged dictionarywill have the sum of the values for each common key. Create

Sample output ('a' 100,:300, ' 200, 'd':400) Exercise 4 Write a function called merge2 that takes two dictionaries as parameters. These in these input lists, the values will always be integers. This function will create a new dictionary that contains everything from the two input dictionaries and return it. If the input lists have common keys, the merged dictionary will have the sum of the values for each common key. Create a few dictionaries, print them to screen using the function created above. After this, merge them using the function you wrote and print the result to screen Sample input d1 -('a':100, 'b': 200, c':300 d2-'a': 300, 'b': 200, 'd :400) Sample output ('a:400, 'b: 400, 'd:400, :300) Exercise5 Write a function called merge3 that takes two dictionaries as parameters. This function will create a new dictionary that contains everything from the two input dictionaries and return it. The only difference is that the values will now be stored in a list, not just as a single value. If the input lists have common keys, the merged dictionary will have a list of the values form in the input dictionaries for the common key. Create a few dictionaries, print them to screen using the function created above. After this, merge them using the function you wrote and print the result to screen. Sample input d1-'a' 100, 200, :300) d2-'a': 300, 'b': 200, 'd :400) Sample output ('a' [100,3001'[200,200],c': 1300], 'd': [400]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!