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 1- 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 2- 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 3- 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()
print(Searching for banana ...)
searchByFruit(banana, fd)
searchByPounds(fd)
Sample run (your program output must look exactly as the following):
Enter the number of fruits: 3
Enter the fruit name: apple
Enter the number of pounds: 50
Enter the fruit name: orange
Enter the number of pounds: 20
Enter the fruit name: banana
Enter the number of pounds: 90
Searching for banana ...
We do have banana with 90 pounds
Enter the number of pounds: 40
50 pounds of apple
90 pounds of banana

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!