For the purposes of this question, if you have a pet of a certain type, that pet needs food, treats, a bed and a house -- but multiple animals of the same kind can share. This function takes what kind of animal or animals you have and returns a shopping list for your pet or pets.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section: Chapter Questions
Problem 4PP
icon
Related questions
Question

For the purposes of this question, if you have a pet of a certain type, that pet needs food, treats, a bed and a house -- but multiple animals of the same kind can share. This function takes what kind of animal or animals you have and returns a shopping list for your pet or pets.

4. pet_shopping_list
For the purposes of this question, if you have a pet of a certain type, that
pet needs food, treats, a bed and a house -- but multiple animals of the
same kind can share. This function takes what kind of animal or animals you
have and returns a shopping list for your pet or pets.
PLAN FOR THIS FUNCTION:
• determine the word for a single kind of the animal. if the input is "mice",
then we want the output to contain "mouse" (don't worry about any
other unusual plurals). Otherwise, look for words that end with "es" and
remove the final "es", so "foxes" goes to "fox". Otherwise, remove a final
"s". Otherwise, assume that the word is singular.
• build and return a shopping list, which will be a list of strings. shopping
lists should be in the shape: ["mouse food", "mouse treats", "mouse bed",
"mouse house")
Sample calls should look like:
>> pet_shopping_list("mice")
['mouse food', 'mouse treats', 'mouse bed', 'mouse house']
> pet_shopping_list("foxes")
['fox food', 'fox treats', 'fox bed', 'fox house']
» pet_shopping_list("giraffe")
['giraffe food', 'giraffe treats', 'giraffe bed', 'giraffe house']
>> pet_shopping_list("raccoons")
['raccoon food', 'raccoon treats', 'raccoon bed', 'raccoon house']
Transcribed Image Text:4. pet_shopping_list For the purposes of this question, if you have a pet of a certain type, that pet needs food, treats, a bed and a house -- but multiple animals of the same kind can share. This function takes what kind of animal or animals you have and returns a shopping list for your pet or pets. PLAN FOR THIS FUNCTION: • determine the word for a single kind of the animal. if the input is "mice", then we want the output to contain "mouse" (don't worry about any other unusual plurals). Otherwise, look for words that end with "es" and remove the final "es", so "foxes" goes to "fox". Otherwise, remove a final "s". Otherwise, assume that the word is singular. • build and return a shopping list, which will be a list of strings. shopping lists should be in the shape: ["mouse food", "mouse treats", "mouse bed", "mouse house") Sample calls should look like: >> pet_shopping_list("mice") ['mouse food', 'mouse treats', 'mouse bed', 'mouse house'] > pet_shopping_list("foxes") ['fox food', 'fox treats', 'fox bed', 'fox house'] » pet_shopping_list("giraffe") ['giraffe food', 'giraffe treats', 'giraffe bed', 'giraffe house'] >> pet_shopping_list("raccoons") ['raccoon food', 'raccoon treats', 'raccoon bed', 'raccoon house']
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage