You are a cook in a busy restaurant. You are writing a program to help you...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You are a cook in a busy restaurant. You are writing a program to help you organize how much of each kind of food you need to cook. Naturally, you decide to take a break from cooking and write a function to help. You decide that your function will take a dictionary as a parameter where the keys are the tables in the restaurant and the values are lists of strings describing the food each table has ordered. Your function returns a dictionary with the totals for how many of each food item you need to cook. For example, say you have 5 tables and 3 dishes: Tables: 11, 12, 13, 14 and 15 Dishes: Vegetarian stew, Steak pie, Poutine Input: You will use the table names as the keys, and use a list of the foods ordered at each table as values. For example your dictionary may look like this: ('t1': ['Vegetarian stew', 'Poutine', 'Vegetarian stew' 1, 't3': [ 'Steak pie', 'Poutine', 'Vegetarian stew'], 't4': [ 'Steak pie', 'Steak pie']) Output: Your function must return a dictionary with the dish as the key, and the number of times that dish was ordered as the value. Given the above input, your function would create and return a dictionary equivalent to the following: ('Vegetarian stew': 3, 'Poutine': 2, 'Steak pie': 3} Here we have started the code for you. Complete it: 8 9 10 11 12 13 455789222 14 15 16 17 18 19 20 21 from typing import List, Dict def get quantities (table_to_foods: Dict[str, List[str]]) -> Dict [str, int]: ***Return a dictionary where each key is a food from table_to_foods and each. value is the quantity of that food that was ordered. The table_to_foods dict has table names as keys (e.g., 't1', '2', and so on) and each value is a list of foods ordered for that table. >>>resultget_quantities (( ... 'tl': [ 'Vegetarian stew', 'Poutine', 'Vegetarian stew'], '+3': [ 'Steak pie', 'Poutine', 'Vegetarian stew'], 't4': ['Steak pie', 'steak pie'])) >>> result == ('Vegetarian stew': 3, 'Poutine': 2, 'Steak pie': 3) True H food_to_quantity = {} #Accumulate the food information here. return food_to_quantity. You are a cook in a busy restaurant. You are writing a program to help you organize how much of each kind of food you need to cook. Naturally, you decide to take a break from cooking and write a function to help. You decide that your function will take a dictionary as a parameter where the keys are the tables in the restaurant and the values are lists of strings describing the food each table has ordered. Your function returns a dictionary with the totals for how many of each food item you need to cook. For example, say you have 5 tables and 3 dishes: Tables: 11, 12, 13, 14 and 15 Dishes: Vegetarian stew, Steak pie, Poutine Input: You will use the table names as the keys, and use a list of the foods ordered at each table as values. For example your dictionary may look like this: ('t1': ['Vegetarian stew', 'Poutine', 'Vegetarian stew' 1, 't3': [ 'Steak pie', 'Poutine', 'Vegetarian stew'], 't4': [ 'Steak pie', 'Steak pie']) Output: Your function must return a dictionary with the dish as the key, and the number of times that dish was ordered as the value. Given the above input, your function would create and return a dictionary equivalent to the following: ('Vegetarian stew': 3, 'Poutine': 2, 'Steak pie': 3} Here we have started the code for you. Complete it: 8 9 10 11 12 13 455789222 14 15 16 17 18 19 20 21 from typing import List, Dict def get quantities (table_to_foods: Dict[str, List[str]]) -> Dict [str, int]: ***Return a dictionary where each key is a food from table_to_foods and each. value is the quantity of that food that was ordered. The table_to_foods dict has table names as keys (e.g., 't1', '2', and so on) and each value is a list of foods ordered for that table. >>>resultget_quantities (( ... 'tl': [ 'Vegetarian stew', 'Poutine', 'Vegetarian stew'], '+3': [ 'Steak pie', 'Poutine', 'Vegetarian stew'], 't4': ['Steak pie', 'steak pie'])) >>> result == ('Vegetarian stew': 3, 'Poutine': 2, 'Steak pie': 3) True H food_to_quantity = {} #Accumulate the food information here. return food_to_quantity.
Expert Answer:
Answer rating: 100% (QA)
python from typing import List Dict def getquantitiestabletofoods Dictstr Liststr Dictstr int Initia... View the full answer
Related Book For
Project Management The Managerial Process
ISBN: 9781260570434
8th Edition
Authors: Eric W Larson, Clifford F. Gray
Posted Date:
Students also viewed these programming questions
-
Recall a work or personal situation in which a particular individual tried to get you or a group to make a change, then respond to the questions below: Provide a little background so that we...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
To load and register a JDBC driver, two popular methods can be used: either using the Class.forName() method or creating a new instance of the Driver class.(True/False)
-
What do you understand by the term first normal form?
-
what ways do authors employ verbal irony, imbuing their prose with layers of complexity through the deliberate use of language to convey meanings contrary to the literal interpretation, thereby...
-
How many ways can a company select 4 candidates to interview from a short list of 12 engineers?
-
In most large corporations, ownership and management are separated. What are the main implications of this separation?
-
Poster instructions: Tools: You can use a poster board or PowerPoint slide. Assignment: Find 3 pictures that illustrate your values. Find 2 pictures that illustrate how you perceive your workplace...
-
a) A venturimeter is in an installation of 100 mm diameter pipe carrying water. The maximum range available in water-mercury differential pressure gauge is 50 cm of mercury deflection. Find the...
-
Stephanie is preparing a presentation on new marketing ideas for a timeshare company that has properties near a coral reef. As she's editing her presentation, she reads the slogan idea, "Experience a...
-
Explain how to calculate a business' accounts receivable turnover. What is a 'good' accounts receivable turnover? Why?
-
What is the difference between incremental costs and avoidable costs?
-
Is a credit balance in the GST control account shown as an asset or a liability in the balance sheet? Why?
-
Explain why past costs are irrelevant.
-
The total increase or decrease for one component of the accounting equation is missing in each situation. i Assets decreased by \(\$ 30000\); liabilities decreased by \(\$ 19500\) ii Owner's equity...
-
How does an agile team maintain requirements? Select only one answer. Every team member maintains a personal backlog of items they are working on. Facilitator/Onsite coordinator maintains the...
-
Hotel Majestic is interested in estimating fixed and variable costs so that the company can make more accurate projections of costs and profit. The hotel is in a resort area that is particularly busy...
-
How easy do you think it is to identify people who respond to challenges?
-
Why would people resist a multiproject resource scheduling system?
-
1 . Can you identify personal examples of white elephants? 2 . What else do you think Olympic organizers could do to make the event more sustainable?
-
The first 5 years of a revenue requirements analysis for a public utility is presented below. The fraction of total capitalization that is debt is 35 percent. Answer the following questions. a. What...
-
True or False: When several independent, indivisible investments are available, form the investment portfolio so that the present worth of the portfolio is maximized.
-
Consolidated Rural Electric Coop (CREC) provides reliable electrical service to a large rural community. "Reading" the meters is very troublesome and costly due to the distance between service...
Study smarter with the SolutionInn App