Question: Use functions, loops, and conditionals as appropriate to complete the following prompts where you manipulate LISTS. book Count Download this starter file: Bookshelf.py Complete the




Use functions, loops, and conditionals as appropriate to complete the following prompts where you manipulate LISTS. book Count Download this starter file: Bookshelf.py Complete the function bookCount(). Note that the program will not run as is because the function is incomplete. The purpose of the function is to count the number of books on your shelf. The function should take a string like the one stored in myShelf and return the number of books listed. The expected output is: How many books? 6 But the code should work for any book shelf that uses the same delimiter. Try with your own list as well as the one ! provided favorite Flower Download this starter file: Flower.py i Complete the function favorite Flower(). Note that the program will not run as is because the function is incomplete. The purpose of the function is to determine if the given flower is in the top three of my favorite flowers. The starter file defines a list of favorite flowers that is ordered most favorite to least favorite. Please pass the flower name and the flower list as arguments in the function. The expected output is: Is lily one of my favorite flowers? True Is orchids one of my favorite flowers? False Is rose one of my favorite flowers? False Bookshelf.py Download Bookshelf.py (348 Bytes) 200M + define our bookshelf myShelf = "Little Women-An Absolutely Remarkable Thing-The Bluest Eyes-Python for Everyone-The Hunger Games-Fun Home" #Function bookCount should take a string and return the number of books on your shelt def bookCount(): aturn into list #count list return print("How many books?", bookcount(myself)) Flower.py Download Flower.py (572 Bytes) ZOOM + #define list of flowers myFlowers = ['daffodil', 'lavendar', 'lly', 'daisy', 'rose', 'hydrangea', dahlia', 'sunflower' #Function that determines if given flower is one of the top three favorites der favoriteFlower(); #check if given flower is in the top three, return True (boolean) it is return print("Is lily one of my favorite flowers?", favoritefldver("lily", myFlowers)) print("Is orchids one of my favorite Flowers? - favoriteFlower("orchids", myFlowers)) print("Is rose one of my favorite flowers?", favoriteFlower("rose", myFlowers)) Missing Nums.py Download MissingNums.py (302 Bytes) ZOOM + #define list of nums al lNums = [4, 7, 6, 10, 32, 0, 51, 0, 89, 100) #def function that replaces zeros with 'missing' def missingNum(): #replace all zeros with 'missing return print("All the nums: ", allNums) updatedList = missingNum(allNums) print("Replaced nums: ", updatedlist) missingNum Download this starter file: Missing Nums. Complete the function missingNum. Note that the program will not run as is because the function is incomplete. The purpose of the function is to replace all instances of zero in the list with the word "missing". The function should take the list and rotum the list once it has been changed. Changing the list may require a forloop and it statements. You may even need to iterate by Index INSTEAD of by value! Just sayin' All the num: (4.7.0.10,320,51,0, 89, 100) Replaced nums: (4.7'missing, 10, 32, 'missing: 51 missing: 89.100)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
