Meow' eats a lot, and she loves to know in gory detail what she eats in every meal. As her assistant, you are going to implement a function mealCal (meal: list[str], recipes: list[str], db: list[str]) -> float that operates as follows: • The parameter meal is a list of strings, listing the dishes she is having. There may be redundant items: if Meow likes it enough, she may consume multiple servings of the same dish. For example, meal ["T-Bone", "T-Bone", "Green Salad1"]. • The parameter recipes is a list of strings, representing a "book" of recipes. For example², recipes ["Pork Stew: Cabbage 5, Carrot 1, Fatty Pork*10", "Green Salad1: Cabbage* 10, Carrot 2, Pineapple*5", "T-Bone: Carrot *2, Steak Meat*1"] Each item is a string indicating the name of the dish, followed by a colon, then a comma-separated list of ingredient names together with their quantities. In the example presented, the item "T-Bone: Carrot 2, Steak Meat *1" ¹a fictitious character from before 2The recipes and nutritional "facts" are totally made up. Homework 6 Intro to Programming indicates that the dish "T-Bone" uses 2 units of Carrot and unit of Steak Meat. • The parameter db is a list of strings, representing a database of how much carbohydrate, protein, and fat each ingredient contains. Each item is listed as the ingredient's name, followed by a colon, and then three comma-separated numbers (int or float) denoting, respectively, the amounts of carb, protein, and fat in grams. Here is an example: db = ["Cabbage: 4,2,0", "Carrot:9, 1,5", "Fatty Pork: 431,1,5", "Pineapple:7,1,0", "Steak Meat: 5,20, 10", "Rabbit Meat: 7,2,20"]. As a specific example, the entry for Cabbage indicates that 1 unit of "Cabbage" has 4g of carbohy- drate, 3g of protein, and Og of fat. • The function then returns the amount of calories resulted from eating this meal. Remember that - Each gram of carbohydrate yields 4 calories. - Each gram of protein yields 4 calories. - Each gram of fat yields 9 calories. To give a complete example, plugging in the sample combination just described into mealCal, we have that mealCal(meal, recipes, db) computes the following: - First, we derive the amount of calories Meow gets from a T-Bone dish. This dish has 2 carrots and 1 unit of steak meat, so that's (9-4+1-4+5-9) x2=85x2= 170 calories from carrots and 5-4+20-4+10-9= 190 calories from the meat. Hence, this dish has 170+ 190 = 360 calories. Then, we derive the amount of calories Meow gets from her other T-Bone dish. The amount is the same: 360 calories. - Then, we derive the amount of calories Meow gets from her salad dish: (4-4+2-4) × 10+ (9- 4+1-4+5-9) x2+(7-4+1-4+0-9) ×5=240+170+ 160 = 570. Hence, mealCal, in this case, will return 1290.0. Remarks: • Your answers may be floating-point numbers; we'll accept any answers within 10-5 of our model answers. • The input ensures: (1) every dish in Meow's meal exists in the recipe; and (2) every ingredient
Meow' eats a lot, and she loves to know in gory detail what she eats in every meal. As her assistant, you are going to implement a function mealCal (meal: list[str], recipes: list[str], db: list[str]) -> float that operates as follows: • The parameter meal is a list of strings, listing the dishes she is having. There may be redundant items: if Meow likes it enough, she may consume multiple servings of the same dish. For example, meal ["T-Bone", "T-Bone", "Green Salad1"]. • The parameter recipes is a list of strings, representing a "book" of recipes. For example², recipes ["Pork Stew: Cabbage 5, Carrot 1, Fatty Pork*10", "Green Salad1: Cabbage* 10, Carrot 2, Pineapple*5", "T-Bone: Carrot *2, Steak Meat*1"] Each item is a string indicating the name of the dish, followed by a colon, then a comma-separated list of ingredient names together with their quantities. In the example presented, the item "T-Bone: Carrot 2, Steak Meat *1" ¹a fictitious character from before 2The recipes and nutritional "facts" are totally made up. Homework 6 Intro to Programming indicates that the dish "T-Bone" uses 2 units of Carrot and unit of Steak Meat. • The parameter db is a list of strings, representing a database of how much carbohydrate, protein, and fat each ingredient contains. Each item is listed as the ingredient's name, followed by a colon, and then three comma-separated numbers (int or float) denoting, respectively, the amounts of carb, protein, and fat in grams. Here is an example: db = ["Cabbage: 4,2,0", "Carrot:9, 1,5", "Fatty Pork: 431,1,5", "Pineapple:7,1,0", "Steak Meat: 5,20, 10", "Rabbit Meat: 7,2,20"]. As a specific example, the entry for Cabbage indicates that 1 unit of "Cabbage" has 4g of carbohy- drate, 3g of protein, and Og of fat. • The function then returns the amount of calories resulted from eating this meal. Remember that - Each gram of carbohydrate yields 4 calories. - Each gram of protein yields 4 calories. - Each gram of fat yields 9 calories. To give a complete example, plugging in the sample combination just described into mealCal, we have that mealCal(meal, recipes, db) computes the following: - First, we derive the amount of calories Meow gets from a T-Bone dish. This dish has 2 carrots and 1 unit of steak meat, so that's (9-4+1-4+5-9) x2=85x2= 170 calories from carrots and 5-4+20-4+10-9= 190 calories from the meat. Hence, this dish has 170+ 190 = 360 calories. Then, we derive the amount of calories Meow gets from her other T-Bone dish. The amount is the same: 360 calories. - Then, we derive the amount of calories Meow gets from her salad dish: (4-4+2-4) × 10+ (9- 4+1-4+5-9) x2+(7-4+1-4+0-9) ×5=240+170+ 160 = 570. Hence, mealCal, in this case, will return 1290.0. Remarks: • Your answers may be floating-point numbers; we'll accept any answers within 10-5 of our model answers. • The input ensures: (1) every dish in Meow's meal exists in the recipe; and (2) every ingredient
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 4 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education