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
daser333 [38]
3 years ago
8

The function below takes two arguments, a dictionary called dog_dictionary and a list of dog names (strings) adopted_dog_names.

The dog dictionary uses dogs' names as the keys for the dictionary. Complete the function to remove all the adopted dogs from the dog_dictionary. Return the dictionary at the end of the function.
Computers and Technology
1 answer:
laiz [17]3 years ago
4 0

Answer:

The solution code is written in Python.

  1. def removeAdoptedDog(dog_dictionary, adopted_dog_names):
  2.    for x in adopted_dog_names:
  3.        del dog_dictionary[x]
  4.    
  5.    return dog_dictionary  
  6. dog_dictionary = {
  7.    "Charlie": "Male",
  8.    "Max" : "Male",
  9.    "Bella" : "Female",
  10.    "Ruby": "Female",
  11.    "Toby": "Male",
  12.    "Coco": "Female",
  13.    "Teddy": "Male"
  14. }
  15. print(dog_dictionary)
  16. adopted_dog_names = {"Ruby", "Teddy"}
  17. print(removeAdoptedDog(dog_dictionary, adopted_dog_names))

Explanation:

Firstly, let's create a function <em>removeAdoptedDog() </em>takes two arguments, <em>dog_dictionary </em>& <em>adopted_dog_names</em> (Line 1)

Within the function, we can use a for-loop to traverse through the <em>adopted_dog_names</em> list and use the individual dog name as the key to remove the adopted dog from <em>dog_dictionary </em>(Line 3). To remove a key from a dictionary, we can use the keyword del.

Next return the updated dog_dictionary (Line 5).

Let's test our function by simply putting some sample records on the <em>dog_dictionary</em> (Line 7 -15)  and two dog names to the <em>adopted_dog_names list</em> (Line 19).

Call the function <em>removeAdoptedDog() </em>by<em> </em>passing the <em>dog_dictionary and adopted_dog_names </em>as arguments. The display result will show the key represented by the<em> adopted_dog_names</em> have been removed from the <em>dog_dictionary </em>(Line 21).

You might be interested in
Students can use eNotes to type notes directly on screen and
zalisa [80]
A. review or print them later
6 0
3 years ago
Read 2 more answers
Use the code below to answer the following questions. Note that the catch statements in the code are not implemented, but you wi
anzhelika [568]

Answer:

d) either e1 or e5

Explanation:

Here, the instruction i1 goes ahead in trying to open the given file through an input stream buffer reader. If the given file name is wrong, it will indicate that an e1 file is not found or if any other IO errors due to invalid stream, no disc in drive e5 IO exception will be drawn.

4 0
3 years ago
What is a power surge?
Damm [24]
D. A spike of electricity. They are fast and have a short duration.
4 0
2 years ago
What is application launchers functions​
andrey2020 [161]
An app launcher replaces the stock user interface for organizing the home screen and app icons predominantly in the Android world; however, they are also available for jailbroken iPhones (see iPhone jailbreaking and Cydia). See Launchpad.
5 0
3 years ago
The process of using the new
IRINA_888 [86]

Answer:

The process of using the new

information system and doing away

with the old system is known as

system <u>development</u>

7 0
2 years ago
Other questions:
  • All animations on the world wide web are flash animations
    11·2 answers
  • On the 74ls74 d flip-flop, the clk input has a small triangle. the pr (preset) and clr (clear) inputs have a circle. what do the
    15·1 answer
  • The file type ____ identifies a word 2013 document.
    11·1 answer
  • Green Field county stadium is planning to conduct a cricket match between two teams A and B. A large crowd is expected in the st
    6·1 answer
  • Sometimes news organizations have biasis because
    5·1 answer
  • Create a datafile called superheroes.dat using any text-based editor, and enter at least three records storing superheroes’ name
    9·1 answer
  • Being nice take the points​
    9·1 answer
  • Please help me ASAP! Here is the question.
    15·1 answer
  • Define management styles
    14·2 answers
  • Under which menu would you be able to see the number of continuous track minutes available on each mounted hard drive at the cur
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!