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




Use functions, loops, and conditionals as appropriate to complete the following prompts where you manipulate LISTS. bookCount Download this starter file: Bookshelf.Rya 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: Flowereya Complete the function favoriteFlower(). 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 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 missing Num Download this starter file: Missing Nums.py a Complete the function missingNum). Note that the program will not run as is because the function is incomplete. Tit. 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 return the list once it has been changed. Changing the list may require a for loop and if statements. You may even need to iterate by index INSTEAD of by value! Just sayin... All the nums: 14.7,0, 10, 32,0.51, 0, 89, 100) Replaced nums: 14.7. 'missing: 10,32, 'missing: 51, 'missing: 89.100) What to Turn In 1. Submit 3 .py files labeled FLastName_BookName.py, FLastName Flower Name.py, and Flastname_MissingNum.py with your code. 2. Submit images (photo or computer generated) of a stack traces of your final code labeled FlastName ListStackTrace png for jpeg, pdf, etc.) #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 shelf def bookCount(): #turn into list #count list return print("How many books?", bookcount (nyShell)) #define list of flowers myFlowers = ['daffodil', 'lavendar', 'lily', daisy', 'rose', 'hydrangea', dahlia', sunflower'] #Function that determines if given flower is one of the top three favorites def favoriteFlower(): #check if given flower is in the top three, return True (boolean) ir 1s return print("In ut one of my favorite flowers?, favorite Flower("Lly", myFlowers)) print("ts orchids one of my favorite flowers?", favoriteFlower("orchids", myFlowers)) print("Is rose one of my favorite flowers?", favoriteFlower("rose", myFlowers)) #define list of nums allNums = [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: al lNums) updatedList = missingNum(al lNums) print("Replaced nums: updatedList) MacBook Pro 80 3 OOO DOO F4 FS F6 ga F7 DII FB DD F9 10 11
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
