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
What is a multipurpose network device?
exis [7]

Answer:

A switch connects multiple devices to a network. ... devices are usually integrated into a multipurpose network device

7 0
3 years ago
What is a coaxial cable?
grin007 [14]

Answer:

A transmission line that consists of a tube of electrically conducting material surrounding a central conductor held in place by insulators and that is used to transmit telegraph, telephone, television, and Internet signals.

Coax, short for coaxial, is a type of cable used to transmit data, the internet, video and voice communications. A coax cable is made up of an aluminum and copper shield with an outer plastic jacket (see below) with the dielectric insulator helping to minimize signal loss.

5 0
2 years ago
Which option allows to change date and time​
tester [92]
The Windows key has the Windows logo on it. Right-click the Date/Time display on the taskbar and then choose Adjust Date/Time from the shortcut menu. The Date and Time dialog box appears. Click the Change Date and Time button.
4 0
3 years ago
Read 2 more answers
What is a computer meaning
goldenfox [79]

Answer:

computer means an electronic machine which process raw data and gives meaningful information to the user

7 0
3 years ago
How do you insert text into a presentation?
ElenaW [278]

Answer:

Its most likely the last one

Explanation:

But like, what kind of quesiton is this?

7 0
3 years ago
Read 2 more answers
Other questions:
  • Who would be a tippee for purposes of insider trading? a. a janitor who gathers information by reading files on corporate counse
    6·1 answer
  • When tcp/ip was developed, the host table concept was expanded into a hierarchical name system for matching computer names and n
    5·1 answer
  • Technician A says that in any circuit, electrical current takes the path of least resistance. Technician B says that while this
    11·2 answers
  • Which is the last step in conducting a URL search?
    6·1 answer
  • The basic input/output system (bios locates the boot loader program on a linux system by reading the __________ on the hard driv
    13·1 answer
  • Complete the statement below using the correct term.<br>Website managers use<br>every day​
    11·2 answers
  • _____ is a problem-solving technique where each problem in a database is stored with a description and keywords that identify it
    10·1 answer
  • One can find mountain ranges, elevation levels, and deserts on a physical map.
    15·2 answers
  • write ms-dos command to list all the files and folders of EIGHT sub directory of C: drive in ascending order according to file n
    5·1 answer
  • Say true or false
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!