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
How to make a Tip Calculator in code?
ki77a [65]
You should have the percentage of tip based on the service that you received.
Then you multiply the percentage of tip by the amount of money that you have to pay for what you bought.
4 0
3 years ago
Match the data type to the given data.
guapka [62]
Float: 26.2
Array: c, o, m, p, u, t, er
Boolean: false
Character: c
7 0
3 years ago
If you’re assigned the job of writing a company newsletter or producing a product brochure, why is it important to learn about t
vitfil [10]

If you’re assigned the job of writing a company newsletter or producing a product brochure, it is important to learn about that document type and review examples that are considered to have a good layout and design because:

  1. It ensures conformity (especially if the organization already has a pattern).
  2. It will aid readability.
  3. It will help to guarantee a result that is satisfactory to the employers.

When given the job of writing a brochure, it is important to review examples that are considered standard.

This is because it will help to ensure an excellent final result that is in harmony with the company's requirements. It will also ensure conformity to standards.

Learn more about document type here:

brainly.com/question/1218796

3 0
2 years ago
For each of the following memory accesses indicate if it will be a cache hit or miss when carried out in sequence as listed. Als
nika2105 [10]

Answer:

Explanation:

Operation Address Hit? Read Value

Read 0x834 No Unknown

Write 0x836 Yes (not applicable)

Read 0xFFD Yes CO

6 0
3 years ago
A teacher is writing a code segment that will use variables to represent a student's name and whether or not the student is curr
SIZIF [17.4K]

Complete Question:

A teacher is writing a code segment that will use variables to represent a student's name and whether or not the student is currently absent. Which of the following variables are most appropriate for the code Segment?

Group of answer choices.

А. A string variable named s and a Boolean variable named a.

B. A string variable named s and a numeric variable named A.

С. A string Variable named studentName and a Boolean variable named isAbsent.

D. A string Variable named studentName and a numeric variable named absences.

Answer:

C. A string variable named studentName and a Boolean variable named isAbsent.

Explanation:

In Computer programming, a variable stores information which is passed from the location of the method call directly to the method that is called by the program.

In this scenario, teacher is writing a code segment that will use variables to represent a student's name and whether or not the student is currently absent.

Hence, the variables which are most appropriate for the code segment are a string variable named studentName and a Boolean variable named isAbsent.

Basically, the string variable named studentName would only accept or hold values that are alphabetic but not numerical value. Thus, the variable studentName would represent the name of a specific student.

Also, the Boolean variable named isAbsent would accept values that are either "True" or "False" because it works on the principle of Boolean logic (0 for false and 1 for true).

4 0
2 years ago
Other questions:
  • If you want to place the insertion point in a cell to edit a specific part of its contents, you can
    5·1 answer
  • How does technology set a negative impact on the adolescent of our society?
    14·1 answer
  • The action in which a router divides and forwards incoming or outbound message traffic to multiple links is known as
    15·1 answer
  • If given the chance to own manage a business,what will be the name of the business?
    11·2 answers
  • If a*b = 2a - 56, calculate the value of<br>3 * 4​
    14·1 answer
  • Read the following example cover letter: To Ms. March: I was excited to see your opening for a customer support specialist with
    13·1 answer
  • You can use this type of program to create a new raster image
    9·1 answer
  • Define the terms data and information ??​
    8·2 answers
  • Any please answer this How much resistance is required to gen-erate 50 mA of current from a 5 volt bat-tery?
    5·1 answer
  • A_______VPN connection is a private network that uses a public
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!