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]
2 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]2 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 does your digital footprint say about you? Does your digital footprint
faust18 [17]
Your digital footprint says a lot about you. It represents your difference from everyone else and that you can’t be exactly like someone else. Your digital footprint also shows that there is one part of you that stays true to itself and never changes. It aligns with a purpose for almost everyone. That purpose is to be yourself because no matter how hard you try to be like someone else, something will always remain true to the real you.

Hope this helps. If this isn’t the type of answer you were looking for, I apologize.
7 0
3 years ago
This is your code.
lubasha [3.4K]

Answer:

35

Explanation:

We will be going inside B array, because he was in second place in array E,and will be the first element of array B, so it's 35

E can be understanded as:

E=[[21, 'dog', 'red'],[35, 'cat', 'blue'],[12, 'fish', 'green']], so, you can see array E as array of arrays or so-called two-dimensional array

6 0
2 years ago
Without this step of the problem solving process you might solve the wrong problem, not know where to start, or not know when yo
STatiana [176]
Prepare should be the answer
7 0
3 years ago
Computer engineering is a career that......
WITCHER [35]

Answer:

Computer engineering is a career that works on the development and research of new technology-related things.

Explanation:

4 0
2 years ago
Martha has a large data list and wants to sort it quickly and efficiently. Which algorithm should Martha use
Elena-2011 [213]

Answer:

quicksort

Explanation:

There are many types of asymptotically efficient sorting algorithms that can be used but one of the more commonly used for large data lists would be quicksort. This is a sorting algorithm that focuses on choosing a value from the list and working around that value in order to sort the data piece by piece. For larger data sets this method is widely used due to its speed and efficiency which is exactly what Martha needs in this scenario.

4 0
3 years ago
Other questions:
  • If you delete a file from removable media, it is stored in the recycle bin where you can recover it until you empty the recycle
    13·1 answer
  • What was bill gates first operating system he created?
    7·1 answer
  • science and technology are interdependent advances in one lead to advances in the other. give an example of this phenomenon.
    5·1 answer
  • HI brainly friends....<br> Pease thanks my answers I will also thank your answers
    11·1 answer
  • This method adds newValue to the list at the specified index. If the index is invalid for the list, throw an IndexOutOfBoundsExc
    13·1 answer
  • Discuss why diffrent user interface require the use of diffrent type of input device<br>​
    14·1 answer
  • What are price comparison websites?
    6·1 answer
  • Compare mini and mainframe computer in terms of speed,memory and storage​
    15·1 answer
  • Which statement is true about encoding in Python?
    7·1 answer
  • The purpose of an Internet _____ is to receive packets and send them along towards their final destination.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!