Question: Question 1 - Write a function named createFruits that creates and returns a dictionary of fruits using this format: key: fruit; value: pounds, where fruit
Question Write a function named createFruits that creates and returns a dictionary of fruits using this format:
key: fruit; value: pounds, where fruit is a string and pounds is an integer.This function asks the user to enter the number of fruits N then use a loop to ask the user for the name and pounds for each of those N fruits.
Question Write a function named searchByFruit that takes two parameter named fruit string and fruitsDict dictionary and checks if this fruit exists in the fruitsDict dictionary.
Then print the fruit with number of pounds if it exists.If the fruit does not exist in the dictionary, print We don't have it
Question Write a function named searchByPounds that accepts one parameter, which is the fruitsDict dictionary
The function asks the user to input a number of pounds then searches the dictionary.Print any fruit with pounds greater than or equal to the number of pounds inputted by the user.Add this code below to your three functions; this code will test your functions to see if they are working:
fd createFruits
printSearching for banana
searchByFruitbanana fd
searchByPoundsfd
Sample run your program output must look exactly as the following:
Enter the number of fruits:
Enter the fruit name: apple
Enter the number of pounds:
Enter the fruit name: orange
Enter the number of pounds:
Enter the fruit name: banana
Enter the number of pounds:
Searching for banana
We do have banana with pounds
Enter the number of pounds:
pounds of apple
pounds of banana
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
