BlockPy: #35.2) Animal Splits Write a function all_cats that consumes a comma-separated string of animals and...
Fantastic news! We've Found the answer you've been seeking!
Question:
![image text in transcribed](https://s3.amazonaws.com/si.experts.images/answers/2024/05/6645fba7bdd82_4396645fba7278ed.jpg)
Transcribed Image Text:
BlockPy: #35.2) Animal Splits Write a function all_cats that consumes a comma-separated string of animals and returns whether all of the animals have "cat" in their name. For example, the string "gerbil, catfish, dog, cat" would return False, but just "cat, catfish" would return True. If the function consumes an empty string, then it returns True. Unit test this function. Console: at, catfish'l, computed answer was I'gerbil, catfish, dog, cat']. Feedback: Unused Variable View Trace The function all_cats was given a definition on line 2, but was never used after that. Evaluate Run Blocks Split Text Reset Import datasets Upload History 1 from cisc108 import assert_equal 2 def all cats (animals): if animals == "": animals_list = animals.split(",") all_contains_cats = True 3 4 return True 5 else: 6 7 8 9 10 11 12 for value in animals_list: if 'cat' not in value: all_contains_cats = False return all contains_cats 13 assert_equal( ["gerbil, catfish, dog, cat"], ["cat, catfish"]) BlockPy: #35.2) Animal Splits Write a function all_cats that consumes a comma-separated string of animals and returns whether all of the animals have "cat" in their name. For example, the string "gerbil, catfish, dog, cat" would return False, but just "cat, catfish" would return True. If the function consumes an empty string, then it returns True. Unit test this function. Console: at, catfish'l, computed answer was I'gerbil, catfish, dog, cat']. Feedback: Unused Variable View Trace The function all_cats was given a definition on line 2, but was never used after that. Evaluate Run Blocks Split Text Reset Import datasets Upload History 1 from cisc108 import assert_equal 2 def all cats (animals): if animals == "": animals_list = animals.split(",") all_contains_cats = True 3 4 return True 5 else: 6 7 8 9 10 11 12 for value in animals_list: if 'cat' not in value: all_contains_cats = False return all contains_cats 13 assert_equal( ["gerbil, catfish, dog, cat"], ["cat, catfish"])
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
Barcelona Machine Tools. Oriol D'ez Miguel S.R.L., a manufacturer of heavy-duty machine tools near Barcelona, ships an order to a buyer in Jordan. The purchase price is 422,000. Jordan imposes a 14%...
-
PLEASE SHOW HOW TO SOLVE USING EXCEL, FOR EXAMPLE: =PV(C42,C41.C40,0,0) I DONT NEED IT SOLVED BY HAND ! I NEED HELP FIGURING HOW TO SOLVE USING EXCEL. THANK YOU ! ALSO, HOW DO YOU CLEAR A "RUN-TIME...
-
Some Practice Problems for the C++ Exam and Solutions for the Problems The problems below are not intended to teach you how to program in C++. You should not attempt them until you believe you have...
-
If a large chilled water plant has 6 chillers and 5 of them are operating at 1 0 0 % , when the operator starts the 6 th chiller, to what percent do the first 5 chillers unload? What formula do you...
-
Are the following data time series? If not, explain why. a) Reports from the Bureau of Labor Statistics on the number of U.S. adults who are employed full time in each major sector of the economy. b)...
-
Discuss specific ways managers can encourage ethical behavior.
-
The market price of a stock may change daily as its shares are traded on a stock exchange. Research and write a brief report about one of the stock exchanges. Describe such things as how a company is...
-
Telly, age 38, has a $140,000 IRA with Blue Mutual Fund. He has read good things about the management of Green Mutual Fund, so he opens a Green Fund IRA. Telly asked for and received his balance from...
-
In this MySQL challenge, your query should return the names of the people who are reported to (excluding null values), the number of members that report to them, and the average age of those members...
-
Write a report on Global Environmental Issues on Population and Climate Change and explain how you think this topic is changing and the direction you believe it is moving toward. What do you think...
-
The visitor center at Zion National Park uses evaporativecooling towers to condition the inside air. During the day, thecenter receives heat from the environment through conduction,convection, and...
-
Bill, the president of a large multihospital healthcare system that is nationally recognized as one of the most successful vertically integrated healthcare systems in the nation. The organization was...
-
Barca Company's B/S at the end of 2019 included the following items: Current assets $1,326,000 Current liabilities Land 36,000 Bonds payable $1,224,000 1,320,000 Building 1,344,000 Common shares...
-
How can HR professionals ensure that training is inclusive and accessible to all employees?
-
How do social institutions like family, education, religion, and the economy perpetuate or challenge patterns of inequality, socialization, and collective identity formation across diverse cultural...
-
Rambo company Ltd. is a manufacturer of chocolates. It was started after John Rambo retired from the Army and decided to make chocolates in the year 1972. When it was started it was manufacturing...
-
A consultant is beginning work on three projects. The expected profits from these projects are $50,000, $72,000, and $40,000. The associated standard deviations are $10,000, $12,000, and $9,000....
-
Briefly describe the various types of logs that can be used for recovery purposes. Why might a combination of logging strategies be used for recovery purposes?
-
The dual recording/mirroring backup strategy does not allow recovery of the database from all types of failure. Briefly describe the situations where recovery can not be accomplished.
-
Briefly explain the process of rolling back the database using beforeimages of the records in the database. Why is it necessary to take beforeimages of records in a list file that are moved because...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App