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]
3 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]3 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
Why linked list is better than an array?
katrin [286]
In conclusion there are many different data structures. Each data structure has strengths and weaknesses which affect performance depending on the task. Today, we explored two data structures: arrays and linked lists. Arrays allow random access and require less memory per element (do not need space for pointers) while lacking efficiency for insertion/deletion operations and memory allocation. On the contrary, linked lists are dynamic and have faster insertion/deletion time complexities. However, linked list have a slower search time and pointers require additional memory per element in the list. Figure 10 below summarizes the strength and weakness of arrays and linked lists.
8 0
3 years ago
An accountant initially records adjusting entries in a(n) _____.
Alexus [3.1K]
Journal!
Adjusting entries are changes to journal entries you've already recorded.
4 0
3 years ago
What is Napoleon's friend's full name? From the Napoleon Dynamite movie.
expeople1 [14]

His friend's full name was Pedro Sanchez :)

7 0
3 years ago
Read 2 more answers
My uh coding teacher would like the class to do little piggy with code.
Digiron [165]

Answer:

see picture below

Explanation:

I added a parameter to factor out the first bit of each sentence into a global variable. If you change for example 'pig' into 'monkey', all sentences will change.

4 0
3 years ago
True or False: It is illegal to park in a location that you block or create a hazard for other vehicles.
Feliz [49]
The answer to question is true
5 0
3 years ago
Read 2 more answers
Other questions:
  • Describe a situation where it would be advantageous to use the copper tape or aluminum foil instead of the A and B push buttons
    7·2 answers
  • Suppose you wish to write a method that returns the sum of the elements in partially filled array. Which is the best choice for
    6·1 answer
  • Consider a classStudent. The following code is used to create objects and access its member functions. Which statement is true a
    6·1 answer
  • A(n) __________ is the unit of file I/O accessed by an application program as a single unit. A(n) __________ is the unit of stor
    5·1 answer
  • An automated search feature used by search engines to find results that match your search terms is called spider or
    13·1 answer
  • Five batch jobs. A through E, arrive at a computer center at almost the same time. They hav e estimated running times of 10, 6,
    14·1 answer
  • From the following list choose all the tasks an operating system performs.
    5·2 answers
  • Beverly is creating a website for her new clothing company. Aside from including photographs, how can she use the index page to
    8·2 answers
  • By including ______
    15·2 answers
  • Melissa is working on her Cell class by adding new methods. However, in her most recent version, she is receiving errors in some
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!