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
Referat noaptea la școala cu sfârșit de groază​
solniwko [45]

Te ajut eu daca vrei tu la refera

7 0
2 years ago
Please Complete in Java a. Create a class named Book that has 5 fields variables: a stock number, author, title, price, and numb
Gala2k [10]

Answer:

Explanation:

The following code is written in Java. I created both versions of the program that was described in the question. The outputs can be seen in the attached images below. Both versions are attached as txt files below as well.

Download txt
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> txt </span>
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> txt </span>
13e8818abb53c8bc7547a966a10a101d.jpg
8623bf9304771a3e1c8581a41a9c11f6.jpg
8 0
2 years ago
A ____ is a structure that allows repeated execution of a block of statements.
Leokris [45]

Answer:

loop

Explanation:

Loop is the one which is used to execute the specific statement again and again until the condition is true.

In the programming, there are 3 basic loop used.

1. for loop

<u>Syntax:</u>

for(initialization, condition, increment/decrement)

{

  statement;

}

the above statement execute until the condition in the for loop true when it goes to false, the loop will terminate.

2. while loop

<u>Syntax:</u>

initialization;

while(condition)

{

  statement;

increment/decrement;

}

it is work same as for loop and the increment/decrement can be write after or before the statement.

3. do while

syntax:

initialization;

do

{

   statement;

   increment/decrement;

}while(condition);

here, the statement execute first then, it check the condition is true or not.

so, if the condition is false it execute the statement one time. this is different with other loops.

3 0
3 years ago
Read 2 more answers
Is Bob Lazar telling a lie/withholding information?
Anon25 [30]

Answer:

I think he may be a nut, but I'm not sure, there's little evidence of what he says to be true.

6 0
3 years ago
When using _____, developers are required to comply with the rules defined in a framework. (Points : 2) inheritance
Nikolay [14]

Answer: Contracts

Explanation:

The contract is the mechanism which is basically used by the developers to follow the set of rules that is defined in the framework with the proper specification in the API ( Application programming interface).

The contract is the proper agreement between the two and more developers so that they must follow the rules that is mentioned in the agreement contract.  

The contract is widely used in the software development process in which all the possible design requirement are mentioned according to the needs of the client.

Therefore, Contract is the correct option.

7 0
3 years ago
Other questions:
  • Alejandra is using a flash drive that a friend gave to her to copy some financial records from the company database so she can c
    12·1 answer
  • Which of the following is a malicious program that can replicate and spread from computer to computer?
    8·2 answers
  • Write a short java method that takes an integer n and returns the sum of all the odd positive integers less than or equal to n.
    5·1 answer
  • You can create a database using one of the many templates available or by creating a new ______ database.
    9·1 answer
  • The means by which an operating system or any other program interacts with the user is called th
    6·1 answer
  • Comet Computer Company will make a splash with psychedelic laptop cover designs scheduled for release next year. The computers d
    11·1 answer
  • You are creating a presentation and you have come to the last slide. you still have more information to add. what should you do?
    10·2 answers
  • What complications are imposed if one tries to implement a dynamic list using a traditional one-dimensional array
    14·1 answer
  • Which type of computer serves as the heart of the computing systems for many, perhaps most, major corporations and government ag
    12·1 answer
  • Who is katie and why is she deleting my answers
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!