Generation

generate functionSun, 11 Dec 2022

Change the code in this program so that the value of 'quantity' is multiplied by the variable 'portions' and the result is displayed: def change_quantity(dish, portions): return dish['quantity'] * portions change_quantity(dish, portions) dish = 'salad' portions = 5 recipe book = { 'salad': [ { 'ingridient_name': 'cheese', 'quantity': 50, 'measure': 'g'} {'ingridient_name': 'tomatoes', 'quantity': 2, 'measure': 'pcs'} {'ingridient_name': 'cucumbers', 'quantity': 20, 'measure': 'g'} {'ingridient_name': 'olives', 'quantity': 10, 'measure': 'g'} {'ingridient_name': 'olive oil', 'quantity': 20, 'measure': 'ml'} {'ingridient_name': 'salad', 'quantity': 10, 'measure': 'g'} {'ingridient_name': 'pepper', 'quantity': 20, 'measure': 'g'} ]}

def prepare_dish(dish, portions): for ingridient in dish: ingridient['quantity'] = ingridient['quantity'] * portions return dish prepare_dish(dish, portions)

Questions about programming?Chat with your personal AI assistant