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: cook_book = { 'pizza': [ {'ingridient_name': 'cheese', 'quantity': 20, 'measure': 'g'}, {'ingridient_name': 'sausage', 'quantity': 30, 'measure': 'gr'}, {'ingridient_name': 'bacon', 'quantity': 30, 'measure': 'gr'} {'ingridient_name': 'olives', 'quantity': 10, 'measure': 'gr'} ]} dish = input('choose a dish: salad, pizza, lemonade ') portions = int(input('Enter number of portions: ')) ingredients = cook_book[dish] for i in ingredients: for value in i.values(): print(value)

def change_quantity(ingridient, portions): return ingridient['quantity'] * portions change_quantity(ingridient, portions)

Questions about programming?Chat with your personal AI assistant