Generation

generate functionSun, 11 Dec 2022

A recipe book is given with information about how many ingredients are needed to prepare a dish per serving. Write a program that will multiply the number of servings to prepare these dishes and display the information about the total amount of ingredients required in the given form. Note: The same ingredients with different dimensions must be counted separately! The result should be: Cheese: 250 g Tomatoes: 10 pcs. Cucumbers: 60g def total_ingredients(cook_book): dish = 'salad' portions = 5 grams = cook_book['quantity'] * portions if key == 'salad': grams = 'quantity' * portions print(grams) cook_book = {'salad': [{'ingridient_name': 'cheese', 'quantity': 50, 'measure': 'g'}, {'ingridient_name': 'tomatoes', 'quantity': 2, 'measure': 'pcs'}, {'ingridient_name': 'cucumbers', 'quantity': 100, 'measure': 'g'}]} total_ingredients(cook_book)

def total_ingredients(cook_book): dish = 'salad' portions = 5 grams = cook_book['quantity'] * portions if key == 'salad': grams = 'quantity' * portions print(grams) cook_book = {'salad': [{'ingridient_name': 'cheese', 'quantity': 50, 'measure': 'g'}, {'ingridient_name': 'tomatoes', 'quantity': 2, 'measure': 'pcs'}, {'ingridient_name': 'cucumbers', 'quantity': 100, 'measure': 'g'}]} total_ingredients(cook_book)

Questions about programming?Chat with your personal AI assistant