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
If you were setting up a network with 100 nodes and you wanted no more than 25 nodes per segment: what devices and connections w
STatiana [176]

Since at present number user or nodes in an organization counts is 100 and it can be further extended. Moreover concurrent at presented is 25 nodes is active.

<u>Explanation:</u>

So as best practice network administrator has keep in mind and select hardware application.

1. Server with high end rams and further extendable.

2. Minimum life of hardware such as routers, switch or managed or firewall should be considered or two years. But to technology improvement it is possible for 1 year only

3. Upgradable hardware appliances and software updates should be possible with mini cost effect.

4. Network security   and update or upgradable workstation or desktop or laptop to be consideration.

5. Functional operation of an organization should run smoothly.

8 0
3 years ago
When measuring processor speed,a megahertz is much faster than a gigahertz.true or fals
Nat2105 [25]

Answer: False

Explanation:

The statement in the question is wrong. When measuring processor speed, a megahertz is slower than a gigahertz.

We should note that:

1 megahertz = 1 million cycles per second

1 gigahertz = 1 billion cycles per second.

Therefore, we can see that a gigahertz is faster than a megahertz.

4 0
3 years ago
Encryption is an important topic in math and computer science. It keeps your personal information safe online.
lys-0071 [83]
Thus is true
Encryption helps to keep data virtually safe
4 0
3 years ago
Question: 4/8
Gemiola [76]

The generated test cases for the function assuming another developer coded the function is given below in a C++ program.

<h3>THE CODE</h3>

#include <iostream>  

#include <iomanip>

#include <string>

using namespace std;

// define the data type "triangletype" with {values}

enum triangleType { scalene, isosceles, equilateral, noTriangle };

// Prototype function which returns the position of triangleType{value}

// Example: Scalene = 0, isosceles = 1, etc. These are zero indexed.

triangleType triangleShape(double a, double b, double c);

// Prototype function which takes the integer value of the

// triangle type and outputs the name of triangle

string shapeAnswer(int value);

int main() {

   double inputA;

   double inputB;

   double inputC;

   cout << "To determine whether a triangle is either:" << endl;

   cout << setw(50) << " - Scalene" << endl; // Unequal in length

   cout << setw(52) << " - Isosceles" << endl; // Two sides equal length

   cout << setw(54) << " - Equilateral" << endl; // All sides equal

   cout << setw(57) << " - Not a triangle" << endl;

   cout << "Enter side A: ";

   cin >> inputA;

   cout << "Enter side B: ";

   cin >> inputB;

  cout << "Enter side C: ";

   cin >> inputC;

   cout << "The triangle is " << shapeAnswer(triangleShape(inputA, inputB, inputC)) << endl;

}

triangleType triangleShape(double a, double b, double c) {

   triangleType answer;

   if ( c >= (a + b) || b >= (a + c) || a >= (b + c) ) {

       answer = noTriangle;

   }

   else if (a == b && b == c) {

       answer = equilateral;

   }

   // Test the 3 options for Isosceles equality

   else if ( (a == b) && (a != c) || (b == c) && (b != a) || (a == c) && (a != b) ) {

       answer = isosceles;

   }

   else {

       answer = scalene;

   }

   return answer;

}

string shapeAnswer(int value) {

   string answer;

  switch (value) {

   case 0:

       answer = "Scalene";

       break;

   case 1:

       answer = "Isosceles";

       break;

   case 2:

       answer = "Equilateral";

       break;

   case 3:

       answer = "Not a triangle";

       break;

   default:

       break;

   }

   return answer;

}

Read more about C++ programs here:

brainly.com/question/20339175

#SPJ1

8 0
2 years ago
Write the statements needed so that the variable secondWord is associated with the second word of the value of sentence . So, if
professor190 [17]

Answer:

Explanation:

String str = "Broccoli is delicious.";

String[] Secondstr = str.split(" ");

System.out.println("second word is " + Secondstr[1]);

3 0
3 years ago
Other questions:
  • To make sure that you do not get too tired when typing for long periods, how often should you get up and stretch? Every 15 minut
    9·1 answer
  • HURRY
    5·1 answer
  • If you're doing a relational comparison, which filter would be available?
    15·1 answer
  • Please answer this I know that no one else does but I can't think right now
    10·1 answer
  • What are the differences in LAN and WAN and how they are used to Increase Cybersecurity
    7·1 answer
  • A specialized security administrator responsible for performing systems development life cycle (SDLC) activities in the developm
    11·1 answer
  • Data types influence the following in the workflow: (Select all that apply)a. the color choices and layout decisions around comp
    15·2 answers
  • I need a utube name for a gaming channel....PLEASE HELP...BRAINLIEST
    5·1 answer
  • What is the theory of relativity? How does it relate to the creation of electricity through solar energy?
    12·1 answer
  • Please help with question
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!