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
nikklg [1K]
2 years ago
9

Taylor and Rory are hosting a party. They sent out invitations, and each one collected responses into dictionaries, with names o

f their friends and how many guests each friend is bringing. Each dictionary is a partial list, but Rory's list has more current information about the number of guests. Fill in the blanks to combine both dictionaries into one, with each friend listed only once, and the number of guests from Rory's dictionary taking precedence, if a name is included in both dictionaries. Then print the resulting dictionary.
Computers and Technology
1 answer:
disa [49]2 years ago
7 0

Answer:

Following are the code to this question:

def combine_guest(guest1, guest2):#defining a method combine_guest that accepts two dictionary

   guest2.update (guest1)#use dictionary guest2 that use update method to update guest2 dictionary

   return guest2#return guest2 dictionary values

Rory_guest= { "Ada":2, "Ben":3, "Dav":1, "Jo":3, "Charry":2, "Terry":1, "bob":4}#defining a dictionary and add value

Taylor_guest = { "Dav":4, "Nan":1, "bobert":2, "Ada":1, "Samantha":3, "Chr":5}#defining a dictionary and add value

print(combine_guest(Rory_guest,Taylor_guest))#calling the combine_guest method

Output:

{'Nan': 1, 'Samantha': 3, 'Ada': 2, 'bob': 4, 'Terry': 1, 'Jo': 3, 'Ben': 3, 'Dav': 1, 'Charry': 2, 'bobert': 2, 'Chr': 5}

Explanation:

In the code a method, "combine_guest" is defined, that accepts two dictionaries "guest1, guest2" inside the method, in which the "guest2" dictionary uses the update method to combine the value of the guest1 dictionary and use a return keyword to return guest2 values.

In the next step, two dictionaries are declared, that holds some values and use a print method to call the "combine_guest" method and prints its return values.  

You might be interested in
Identify a major drawback of browsing web pages on mobile devices.
Pavlova-9 [17]
It was way too much of a drawback
5 0
3 years ago
Which of the following statements is true about biometrices as an authentication method
matrenka [14]

Answer:

what are the statements?

Explanation:

7 0
3 years ago
A file name extension provides what information about a file?
ASHA 777 [7]
In a file extension, it tells what type of file it is and tells what compiler to run the code.
8 0
2 years ago
Read 2 more answers
Which approach is ideal for ensuring that a Webpage is maintained and does not appear neglected to users?
Greeley [361]

Answer:

D

Explanation:

I think putting hyperlink in essential pages is a good idea as it may guide a user

8 0
3 years ago
Integers and booleans. Write a program RightTriangle that takes three int command-line arguments and determines whether they con
icang [17]

Answer:

<em>The programming language is not stated;</em>

<em>I'll answer using C++</em>

#include<iostream>

#include<cmath>

using namespace std;

int main()

{

int side1, side2, side3;

cout<<"Enter the three sides of the triangle: "<<endl;

cin>>side1>>side2>>side3;

if(side1<=0 || side2 <= 0 || side3 <= 0) {

 cout<<"Invalid Inputs";

}

else {

 if(abs(pow(side1,2) - (pow(side2,2) + pow(side3, 2)))<0.001) {

  cout<<"Right Angled";

 }

 else if(abs(pow(side2,2) - (pow(side1,2) + pow(side3, 2)))<0.001) {

  cout<<"Right Angled";

 }

 else if(abs(pow(side3,2) - (pow(side2,2) + pow(side1, 2)))<0.001) {

  cout<<"Right Angled";

 }

 else {

  cout<<"Not Right Angled";

 }

}

return 0;

}

Explanation:

The following line declares the three variables

int side1, side2, side3;

The next line prompts user for input of the three sides

cout<<"Enter the three sides of the triangle: "<<endl;

The next line gets user input

cin>>side1>>side2>>side3;

The following if condition checks if any of user input is negative or 0

<em> if(side1<=0 || side2 <= 0 || side3 <= 0) { </em>

<em>  cout<<"Invalid Inputs"; </em>

<em> } </em>

If otherwise

else {

The following if condition assumes that side1 is the largest and test using Pythagoras Theorem

<em>if(abs(pow(side1,2) - (pow(side2,2) + pow(side3, 2)))<0.001) { </em>

<em>   cout<<"Right Angled"; </em>

<em>  } </em>

The following if condition assumes that side2 is the largest and test using Pythagoras Theorem

<em>  else if(abs(pow(side2,2) - (pow(side1,2) + pow(side3, 2)))<0.001) { </em>

<em>   cout<<"Right Angled"; </em>

<em>  } </em>

The following if condition assumes that side3 is the largest and test using Pythagoras Theorem

<em>  else if(abs(pow(side3,2) - (pow(side2,2) + pow(side1, 2)))<0.001) { </em>

<em>   cout<<"Right Angled"; </em>

<em>  } </em>

If none of the above conditions is true, then the triangle is not a right angles triangle

<em>  else { </em>

<em>   cout<<"Not Right Angled"; </em>

<em>  } </em>

}

return 0;

Download cpp
4 0
3 years ago
Other questions:
  • To change the overall design of an entire document to include colors, fonts, and effects, a user should apply a?
    8·2 answers
  • The following 2D array has been created:
    12·2 answers
  • What should a safe username do?
    14·2 answers
  • Given: The following if statement uses an overloaded &gt; operator to determine whether the price of a Car object is more than $
    5·1 answer
  • What aspect of web design is Gloria following when she uses the same color scheme throughout a web page?
    12·1 answer
  • What is the main purpose of cutting plane line arrows?
    7·1 answer
  • A ________ database state is one in which all data integrity constraints are satisfied
    15·2 answers
  • If you wanted to make the system sequentially consistent, what are the key constrains you need to impose
    6·1 answer
  • What is required to become a good critical thinker? Use a process when dealing with a big issue. Practice the right skills over
    9·1 answer
  • How do I create a powershell script to make a Windows user account that is a non-admin user
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!