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
Which CSS attribute would change an element's font color to blue? font-color: blue; background: blue; color: blue; background-co
olchik [2.2K]
The Answer is color:blue for changing an element's font color to blue
8 0
4 years ago
Read 2 more answers
The part of the computer that contains the brain or central processing unit is also know as the
mart [117]
The part of the computer that contains the brain is called the motherboard.
3 0
3 years ago
Read 2 more answers
Now now now now mowewweedeeee
gavmur [86]

Answer:

15

Inside the type declaration, you specify the maximum length the entry can be. For branch, it would be 15.

I can't seem to type the full "vc(15)" phrase because brainly won't let me.

4 0
3 years ago
Write a two to three sentence response to the following question:
nlexa [21]

Answer:

Functions can be useful for many reasons, it is one of the main components to learn in writing code. Without functions code would not be where it is today.

Explanation:

5 0
2 years ago
In windows, a(n) ________ follows the file name and a period and indicates the file type.
larisa [96]
Ans : Extention

In windows, a(n) extension follows the file name and a period and indicates the file type.
4 0
4 years ago
Other questions:
  • What is the most efficient way to include a space after each paragraph?
    13·2 answers
  • How long does it take a letter to arrive?
    9·1 answer
  • Why is e-mail better for informative and positive messages than for negative ones?
    6·1 answer
  • An information security ________ is a specification of a model to be followed during the design, selection, and initial and ongo
    11·2 answers
  • A computer has the following parameters Operation Frequency Cycles Arithmetic/Logical instructions 65% 1 Register load operation
    11·1 answer
  • In his article “is google making up stupid” Nicholas Carr uses a metaphor to suggest that
    11·2 answers
  • Using the Vigenere cipher, does the length of the key matter?
    8·1 answer
  • What is the definition of trouble shooting.
    12·1 answer
  • What is the purpose of the Subtotal feature?
    9·1 answer
  • find_cow(name, cows) Given a name and a Python list of Cow objects, return the Cow object with the specified name. If no such Co
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!