In: Computer Science
Did you know that there are over 500 types of bananas in the world? Did you also know that bananas are an excellent source of potassium, fiber, and vitamin B-6 as well as serve as a powerful antioxidant? However, most people might not be aware of the prolific amount of banana consuming possibilities that are available to them. Wouldn't it be amazing if we have a program that would randomly recommend a type of banana for someone to eat every day as part of a complete and balanced breakfast. However, say you don't like bananas and would prefer apples (over 2000 varieties) or kiwi fruit (50 types).
Your task is to build a program that randomly recommends a different kind of one type of fruit each day. The user should be able to pick from a menu of at least three different kinds of fruit (banana is a required selection). The program should also randomly select a new fruit variant for all 30 days of a month. For example, I should be able to choose between: banana, apple, and kiwi. I will select kiwi. It will then produce a randomly selected list of 30 different types of kiwi and present them in a list. If I run the program again and select kiwi, then it will return a new list of kiwi.
Your program should practice a separation of concerns, select from the list randomly, and provide a menu or display.
import random
Fruits = ["Banana","Apples","Kiwi","Mango"]
Varieties = {"Banana": ['Chingan banana','Lacatan banana','Lady Finger banana','Pisang jari buaya','Señorita banana','Sinwobogi banana','Dwarf Cavendish','Giant Cavendish','Grand Nain','Masak Hijau','Robusta','Red Dacca','Dwarf Red banana','Gros Michel banana','East African Highland bananas','Maqueño banana','Popoulu banana','Mysore banana','Pisang Raja banana','French plantain','Green French banana','Horn plantain & Rhino Horn banana','Nendran banana','Pink French banana','Tiger banana','Pome banana','Prata-anã banana','Latundan banana','Bluggoe banana','Silver Bluggoe banana','Pisang Seribu banana','plu banana','French plantain','Green French banana','Horn plantain & Rhino Horn banana','Nendran banana','Pink French banana','Tiger banana'],
"Apples": ['Apple_v_1','Apple_v_2','Apple_v_3','Apple_v_4','Apple_v_5','Apple_v_6','Apple_v_7','Apple_v_8','Apple_v_9','Apple_v_10','Apple_v_11','Apple_v_12','Apple_v_13','Apple_v_14','Apple_v_15','Apple_v_16','Apple_v_17','Apple_v_18','Apple_v_19','Apple_v_20','Apple_v_21','Apple_v_22','Apple_v_23','Apple_v_24','Apple_v_25','Apple_v_26','Apple_v_27','Apple_v_28','Apple_v_29','Apple_v_30','Apple_v_31','Apple_v_32','Apple_v_33','Apple_v_34','Apple_v_35'],
"Kiwi": ['Kiwi_v_1','Kiwi_v_2','Kiwi_v_3','Kiwi_v_4','Kiwi_v_5','Kiwi_v_6','Kiwi_v_7','Kiwi_v_8','Kiwi_v_9','Kiwi_v_10','Kiwi_v_11','Kiwi_v_12','Kiwi_v_13','Kiwi_v_14','Kiwi_v_15','Kiwi_v_16','Kiwi_v_17','Kiwi_v_18','Kiwi_v_19','Kiwi_v_20','Kiwi_v_21','Kiwi_v_22','Kiwi_v_23','Kiwi_v_24','Kiwi_v_25','Kiwi_v_26','Kiwi_v_27','Kiwi_v_28','Kiwi_v_29','Kiwi_v_30','Kiwi_v_31','Kiwi_v_32','Kiwi_v_33','Kiwi_v_34','Kiwi_v_35'],
"Mango": ['Mango_v_1','Mango_v_2','Mango_v_3','Mango_v_4','Mango_v_5','Mango_v_6','Mango_v_7','Mango_v_8','Mango_v_9','Mango_v_10','Mango_v_11','Mango_v_12','Mango_v_13','Mango_v_14','Mango_v_15','Mango_v_16','Mango_v_17','Mango_v_18','Mango_v_19','Mango_v_20','Mango_v_21','Mango_v_22','Mango_v_23','Mango_v_24','Mango_v_25','Mango_v_26','Mango_v_27','Mango_v_28','Mango_v_29','Mango_v_30','Mango_v_31','Mango_v_32','Mango_v_33','Mango_v_34','Mango_v_35']}
print("Hey..Welcome to fruit selector")
print("Enter serial number to select fruit")
serial = 0
for i in Fruits:
serial = serial + 1
print(serial,".",i)
choice = input("Enter your choice:")
choice = int(choice)
if choice<1 or choice>len(Fruits):
print("***Invalid Response***")
else:
print()
print("Following are the varieties of",Fruits[choice-1], " you need to try")
suggest = random.sample(Varieties.get(Fruits[choice-1]), 30)
serial = 0
for i in suggest:
serial = serial + 1
print("Day:",serial,i)
Please note the varieties of fruits are not real ones, they are just for the understanding of the program