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
Which of the following qualities are generally required of both managers and
professor190 [17]

Answer:

C

Explanation:

beacuse you need to be respectful and smart.

8 0
3 years ago
If an excel column will contain prices of smartphones, which number format should you uss
DENIUS [597]

Answer:

You can use number formats to change the appearance of numbers, including dates and times, without changing the actual number. The number format does not affect the cell value that Excel uses to perform calculations. The actual value is displayed in the formula bar. Excel provides several built-in number formats.

Explanation:

5 0
3 years ago
If you insert a picture, resize and reposition it, and then change to a different picture, you must modify the new picture to
Mashcka [7]

Answer:

false , that is not true

Explanation:

because a person can change to a different picture , but it Is not by force it will have a match to the original

3 0
2 years ago
Read 2 more answers
Write a program that prompts for a file name and then reads the file to check for balanced curly braces, {; parentheses, (); and
Phoenix [80]

Answer:

Explanation:

The program is written in C++

/*

 C++ Program to check for balanced parentheses in an expression using stack.

 Given an expression as string comprising of opening and closing characters

 of parentheses - (), curly braces - {} and square brackets - [], we need to  

 check whether symbols are balanced or not.  

*/

#include<iostream>

#include<stack>

#include<string>

using namespace std;

// Function to check whether two characters are opening  

// and closing of same type.  

bool ArePair(char opening,char closing)

{

if(opening == '(' && closing == ')') return true;

else if(opening == '{' && closing == '}') return true;

else if(opening == '[' && closing == ']') return true;

return false;

}

bool AreParanthesesBalanced(string exp)

{

stack<char>  S;

for(int i =0;i<exp.length();i++)

{

 if(exp[i] == '(' || exp[i] == '{' || exp[i] == '[')

  S.push(exp[i]);

 else if(exp[i] == ')' || exp[i] == '}' || exp[i] == ']')

 {

  if(S.empty() || !ArePair(S.top(),exp[i]))

   return false;

  else

   S.pop();

 }

}

return S.empty() ? true:false;

}

int main()

{

/*Code to test the function AreParanthesesBalanced*/

string expression;

cout<<"Enter an expression:  "; // input expression from STDIN/Console

cin>>expression;

if(AreParanthesesBalanced(expression))

 cout<<"Balanced\n";

else

 cout<<"Not Balanced\n";

}

5 0
3 years ago
comparative clinical and cost analysis between surgical and non-surgical intervention for knee osteoarthritiis
solmaris [256]

To assess the treatment options and costs for osteoarthritis of the knee (OAK), a condition that affects the knee joint and progresses over time owing to cartilage and bone deterioration.

Methods: Over the course of two years, we prospectively examined the clinical results and quantified cumulative direct expenses of patients with OAK sent to our multidisciplinary OA programme.

A total of 133 patients were evaluated. All showed radiographic signs consistent with moderate to severe OAK. We tracked and examined changes in the Western Ontario McMaster Osteoarthritis Index (WOMAC), Minimal Clinically Important Improvement (MCII), and BMI.

The total direct expenditures for all subjects' medical and surgical care during a two-year period were calculated.

Learn more about osteoarthritis:

brainly.com/question/28546590

#SPJ4

5 0
1 year ago
Other questions:
  • An administrator working on a Windows Server 2016 Server Core installation needs to disable DHCP on all interfaces on the server
    12·1 answer
  • Proxy servers and ACLs on network devices are examples of non-security devices with security features, while firewalls and IDS/I
    7·1 answer
  • Does two core processors mean that it is twice as fast do you agree? why?
    13·1 answer
  • What is faster C++ or go lang
    15·1 answer
  • How are keyboards applied in the real world
    13·1 answer
  • Using language c, find the nth Fibonacci, knowing that nth Fibonacci is calculated by the following formula: - If n = 1 Or n = 2
    9·1 answer
  • Explain how communication is smooth and efficient working​
    13·2 answers
  • What is the best file manager for windows 10?
    5·2 answers
  • An international fast-food chain is looking for opportunities to leverage the Cloud to gain insights into customer data, includi
    10·1 answer
  • A technique that was developed to determine whether a machine could or could not demonstrate the artificial intelligence known a
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!