Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def get_by_diet(animal_d, diet): Consider a dictionary, animal_d, where the keys are names of animals, and the values are descriptions of their diets. The function should

def get_by_diet(animal_d, diet): Consider a dictionary, animal_d, where the keys are names of animals, and the values are descriptions of their diets. The function should search in the dictionary for animals that are labeled as diet, put them into a list and return the sorted list.

o animal_d: a dictionary that maps animal names to their diet description.

o diet: the diet to search for.

o Return value: asciibetically sorted list of animals that are labeled as diet.

? Examples:

o get_by_diet({'deer':'herbivore', 'bear':'omnivore'}, 'herbivore') ? ['deer']

o get_by_diet({'lion':'carnivore', 'penguin':'piscivore'}, 'omnivore') ? [ ]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

8. Do the organizations fringe benefits reflect diversity?

Answered: 1 week ago