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
In what document does the program manager (pm) address the demilitarization and disposal requirements?
Nana76 [90]

Life Cycle Sustainment Plan (LCSP) is the document that the program manager (pm) addresses the demilitarization and disposal requirements.

<h3>What is Life Cycle Sustainment Plan?</h3>

Life Cycle Sustainment Plan is a plan or service that works during the trade of weapons or system work regarding militarization. This system works on the development and handling of the weapon system.

So, Life Cycle Sustainment Plan will be used in the demilitarization and management requirements.

Thus, the name of the document program is Life Cycle Sustainment Plan.

To learn more about Life Cycle Sustainment Plan, refer to the below link:

brainly.com/question/1272845?referrer=searchResults

#SPJ1

3 0
1 year ago
Vadik is creating a program where the user inputs their grade level and the program tells them which sports teams they are allow
Lelechka [254]
He should use if, elif, else
4 0
2 years ago
Read 2 more answers
Security controls are measures taken to protect systems from attacks on the integrity, confidentiality, and availability of the
pychu [463]

Answer:

ADMINISTRATIVE CONTROL

Explanation:

If a potential employee is required to undergo a drug screening an Administrative Control is what will be conducted on the employee because

Administrative controls are training, procedure, policy that limit or prevent exposure of an individual to hazards. Examples of administrative controls include training, supervision, timing of work. Administrative controls are also changes in work procedures such as written safety policies, rules, supervision which is the reason the employee has to undergo drug screening using Administrative controls.

6 0
3 years ago
2. Read the following scenarios about how three different programmera approach
zheka24 [161]

Answer: A or B

Explanation: I think it's A or B Because they are the ones that make more sence

4 0
2 years ago
Read 2 more answers
What does artifishal inteligence mean
Umnica [9.8K]

looks Theory and development of computer systems able to perform tasks that normally requires human intelligence

4 0
3 years ago
Read 2 more answers
Other questions:
  • Algorithm for converting decimal into binary.
    7·1 answer
  • When cleaning a firearm, what end of the firearm should you generally clean from?
    11·2 answers
  • What is one of the benefits of using templates for your email marketing campaigns?
    10·1 answer
  • Define get_date() function.
    6·1 answer
  • Write a technical term for following statements
    15·1 answer
  • Hello people, I was wandering if I could get some people to complete this questionnaire for my business course. It would be very
    5·1 answer
  • Write a Python function that join the two string and print it ​
    14·2 answers
  • How do you convert an algorithm to make it possible for a computer to read
    6·1 answer
  • Chức năng của hàm MOD(number, divisor)?
    7·1 answer
  • How to send an email to multiple recipients individually outlook
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!