Question: You are asked to write a program that finds a recipe either based on its food title or its required ingredients. First, you need



You are asked to write a program that finds a recipe either based on its food title or its required ingredients. First, you need to construct a recipe dictionary by passing the food titles as keys and the required ingredient lists as values. Use the content provided in Table 1 for this step. Table 1. There are recipes available for only six foods. Their titles and required ingredients are provided here. Food Ingredients omelette tea soup salad eggs water tea leaves lentil onion tomato cucumber lettuce water butter sandwich bread pudding cornstarch flour cheese tomato lettuce sugar milk Preparing such a dictionary is quite simple, you only need to map each key to a list value in curly brackets and record it as a variable. Then, you can access each list by its respective key and perform any of the list operations. An example is as follows: >>>print(characters ["gimli"]) ['dwarf', 'warrior', 'melee attack'] >>>print(characters ["gimli"][2]) melee attack >>> characters = { "legolas": ["elf", "archer", "ranged attack"], "gimli": ["dwarf", "warrior", "melee attack"], "gandalf": ["ainur", "wizard", "ranged attack"]} Next, you need to write separate functions for searching a recipe by its food title and for searching any recipes that can be used with the available ingredients. Both functions need to print their search results by either stating that there are no available recipes or showing the ingredients required for the found recipe(s). The search with available ingredients should be more intricate: you need to check each recipe available and determine if the ingredients required for any of them are present in the user provided list. (Hint: You can do this multiple ways. One is by using counters; loop through the lists in the dictionary and count each recipe's ingredients found in the user provided ingredient list.) You should show the recipes with all ingredients present at the very end. Lastly, you need to ask the user to select one of these search methods in your main function and ask inputs to run the related function according to the user's selection. Note that both these search options should be case insensitive. Also, if the user chooses to search a recipe based on available ingredients, you need to ask these ingredients one by one. At this point, you should also check if the user provided ingredient is even present in any of the recipes. (Hint: You can simply write a list at the start of your program that contains the ingredients in Table 1 to check the input ingredients.) You should ask for a different input for that ingredient if it is not present. Please read the following instructions before starting.: Make sure you place comments in your program. Place your name, ID and date the program was written as comments at the top. You should only use the features and commands you have learnt until this homework was given. Do NOT use commands such as BREAK, CONTINUE, EXIT, QUIT, etc. that prematurely stop a loop or stop your program. Sample outputs if search by food is selected are as follows: Enter 1 to search for ingredients of a food, enter 2 to search a food based on available ingredients: 0 Invalid selection. Enter 1 or 2: 3 Invalid selection. Enter 1 or 2: 1 >>> Enter food name to search its recipe: cake !Result! Recipe for cake was not found. Enter 1 to search for ingredients of a food, enter 2 to search a food based on available ingredients: 1 >>> Enter food name to search its recipe: Soup !Result! Recipe for soup requires the following ingredients: water lentil onion Sample outputs if search by available ingredients is selected are as follows: Enter 1 to search for ingredients of a food, enter 2 to search a food based on available ingredients: 2 >>> Enter amount of ingredients that are available: 3 1. ingredient: WATER 2. ingredient: Eggs 3. ingredient: onion Searching... !Result! The provided ingredients are not enough for cooking with the recipes available. Enter 1 to search for ingredients of a food, enter 2 to search a food based on available ingredients: 2 >>> Enter amount of ingredients that are available: 5 1. ingredient: water 2. ingredient: EGGS 3. ingredient: Onion 4. ingredient: mushroom Item is not found in any recipe, enter another: sausage Item is not found in any recipe, enter another: butter 5. ingredient: Tea Leaves Searching... !Result! The following food(s) can be prepared: omelette -- ingredients: eggs butter tea ingredients: water tea leaves
Step by Step Solution
3.40 Rating (163 Votes )
There are 3 Steps involved in it
Recipe Dictionary recipedict omelette eggs water butter tea leaves soup water lentil onion salad tom... View full answer
Get step-by-step solutions from verified subject matter experts
