Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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,

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

More Books

Students also viewed these Databases questions

Question

Explain the purpose of pro forma financial statements.

Answered: 1 week ago