1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Crazy boy [7]
3 years ago
5

Write a Python function merge_dict that takes two dictionaries(d1, d2) as parameters, and returns a modified dictionary(d1) cons

tructed using the following rules. The rules for addition into the new dictionary are as follows: Add key/value pairs from d2 into d1. If a key from d2 already appears in d1: the new value in d1 is the sum of the values If a key appears only in d1 or d2, then the new value in d1 is the original value from the dictionary that contained this key. Finally, return d1
Computers and Technology
1 answer:
OLga [1]3 years ago
7 0

Answer:

# We define the function merg_dict with the two dictionaries d1 and d2 that it #will take.

def merge_dict(d1,d2):

      for key in d2:

               if key in d1:

                   d1[key] = d1[key] + d2[key]

               else:

                   d1[key] = d2[key]  

          return d1

# We define the parameters of the dictionary d1 and d2

d1 = {'a': [1, 2, 3], 'b': [2, 2, 2], 'c': [1,2,3]}

d2 = {'a': [4,4,4], 'c': [3,3,3]}

#Next we call on the function merge_dict

print(merge_dict(d1,d2)

We'll obtain the following as output:

{'a': [1,2,3,4,4,4], 'b': [2,2,2], 'c': [1,2,3,3,3,3]}

You might be interested in
Small text files used by websites to track potential customers' visits to a website and provide details on how the customer has
andrew-mc [135]
They are called cookies. 
3 0
3 years ago
Search for and list an internet websites that defines plagiarism and discusses how to avoid it
Korvikt [17]
Here are the sites that defines plagiarism and how to avoid it:
1. http://www.plagiarism.org/article/what-is-plagiarism
2. https://en.wikipedia.org/wiki/Plagiarism
3. https://writingcenter.unc.edu/tips-and-tools/plagiarism/
4. http://gethelp.library.upenn.edu/guides/engineering/ee/plagiarize.html
5. http://www.aresearchguide.com/6plagiar.html
8 0
3 years ago
Give 3 ways you can get creative and personal while creating a PowerPoint.
kondor19780726 [428]

Answer:

People come to listen to you – your thoughts, interpretations and insights. Fancy transitions, clips, and tons of text steal from your content and delivery.

Remember: every time you hit that clicker the audience leaves you and goes to the screen.

Explanation:

7 0
4 years ago
What is spam? a type of virus that spreads from computer to computer through a network connection a type of virus that targets p
Bas_tet [7]

Answer:

This is a pretty obvious answer.

An unwanted e-mail sent in bulk from people or organizations.

Explanation:

8 0
3 years ago
Name the tools and materials used in electrical installation job below.​
kow [346]
Voltage tester, Circuit finder, Screwdrivers and nut drivers specific to electricians, Pliers, measuring tape
8 0
3 years ago
Other questions:
  • An element in a web page that connects to a different location in the same page or a different page is a _____.
    8·1 answer
  • The amount of vertical space between lines within paragraphs
    9·1 answer
  • Siva added a "Contact Form" to her website.
    10·1 answer
  • Does the Main Content (MC) of a web page include searchboxes?
    10·1 answer
  • Five aplications of ict​
    10·1 answer
  • Select the qualification that is best demonstrated in each example. Trinity recommends investment strategies to customers. Laris
    10·2 answers
  • A typical day in programming and software development would involve
    7·1 answer
  • Which layer of the iOS architecture is responsible for text and typography?
    14·2 answers
  • What are computer specification​
    12·2 answers
  • The specialized programs used by the operating systems to help ensure that memory is used properly and there are no memory confl
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!