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
Write the definition of a function named averager that receives a double parameter and returns-- as a double -- the average valu
vladimir1956 [14]

Answer:

double averager (double &newNumber)

{

static double sum = 0.0;

static int counter = 0;

counter++;

sum += newNumber;

return sum / counter;

}

Explanation:

This exercise is for you to understand how to use variables in functions that have scope outside of the function. The static keyword before a initialising a variable whether int or double or float or string, place the variable on the STATIC MEMORY. This means that when the function ends, those static variables are still usable and can be manipulated with the same stored values.  So when the function sees the

static double sum = 0.0;

for the second time it IGNORES it and continues with the previously stored value.

7 0
3 years ago
I need help 50 points and brainiest if you answer
Troyanec [42]

Answer:

200

Explanation:

6 0
3 years ago
Read 2 more answers
Navigational signs on the highway are often which colors?
scoundrel [369]

Answer:D

Explanation:

8 0
3 years ago
Read 2 more answers
Just as arrays can only have a, set at the time the array is declared, a parameter list also can only have a fixed number of ele
Maslowich
<h2>The given statement is true.</h2>

Explanation:

In some programming language, arrays have a fixed size and the dimension should be specified at the time of declaration.

If you specify array without defining the size, the compiler will give "compile time" error since it consider the problem as syntax error.

Also, the size cannot be altered as and when needed.

But there are some programming languages which allows arrays to increase or decrease in type. But those will be an object of a class. It will not simple like a primitive type.

8 0
3 years ago
A ________ is a material deficiency, or combination of significant deficiencies, that results in more than a remote likelihood t
VLD [36.1K]

Answer:

a.material control failure

Explanation:

A material control failure is a material deficiency, or combination of significant deficiencies, that results in more than a remote likelihood that a material mis-statement in the annual or interim financial statements will not be prevented or detected.

7 0
3 years ago
Other questions:
  • Google Slides saves your work to Google Drive. PowerPoint has the option to save to OneDrive. Both of these solutions are in the
    9·1 answer
  • Which forensics tool would you use to reveal recent pages viewed via the internet explorer browser?
    10·1 answer
  • Plz help me of this answer<br><br><br>language:python​
    7·2 answers
  • Which agency coordinate the Internet's IP addressing and DNS system.
    15·1 answer
  • Which documents might an employer expect to find in a career portfolio?
    15·2 answers
  • What is "mob of the dead"?
    7·1 answer
  • Interstate highway numbers Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 of 95) go north/south, an
    8·1 answer
  • In a finite state machine, state transitions happen only: a. When the reset causes a clock pulse on the D outputs of the flip-fl
    11·1 answer
  • After reading his e-mail messages, Orlando became very frustrated. Many of the messages he received did not conform to netiquett
    6·1 answer
  • 3) The director tells you to truck left, you must:
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!