Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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 are a cook in a busy restaurant. You are writing a program to help you organize how much of each kind of 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

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.

Step by Step Solution

3.44 Rating (154 Votes )

There are 3 Steps involved in it

Step: 1

python from typing import List Dict def getquantitiestabletofoods Dictstr Liststr Dictstr int Initia... blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Project Management The Managerial Process

Authors: Eric W Larson, Clifford F. Gray

8th Edition

1260570436, 978-1260570434

More Books

Students explore these related Programming questions

Question

=+What can you conclude?

Answered: 3 weeks ago