/
VGorobchenko
/
HMWRK
Обзор
Документация
Войти
/
VGorobchenko
/
HMWRK
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
task_2.py
31 строка
895 B
urpdvk
first_commit
06 май 2026, 13:51
06 май 2026, 13:51
be870ec
Код
Авторство
О чём код?
# Задача №2 from task_1 import read_cook_book def get_shop_list_by_dishes(dishes, person_count, cook_book): shop_list = {} for dish in dishes: for ingredient in cook_book[dish]: name = ingredient['ingredient_name'] quantity = ingredient['quantity'] * person_count measure = ingredient['measure'] if name in shop_list: shop_list[name]['quantity'] += quantity else: shop_list[name] = { 'measure': measure, 'quantity': quantity, } return shop_list if __name__ == '__main__': cook_book = read_cook_book('recipes.txt') shop_list = get_shop_list_by_dishes( ['Запеченный картофель', 'Омлет'], 2, cook_book ) for name, info in shop_list.items(): print(name, info)