/
Marvik_dev
/
Open_and_read_file
Обзор
Документация
Войти
/
Marvik_dev
/
Open_and_read_file
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
task_2.py
31 строка
905 B
Marvik_dev
upload files
11 дек 2025, 10:58
11 дек 2025, 10:58
d38a6a7
Код
Авторство
О чём код?
from task_1 import read_cook_book def get_shop_list_by_dishes(dishes, person_count, cook_book): shop_list = {} for dish in dishes: if dish not in cook_book: continue for item in cook_book[dish]: ingredient = item['ingredient_name'] quantity = item['quantity'] * person_count measure = item['measure'] if ingredient not in shop_list: shop_list[ingredient] = { 'measure': measure, 'quantity': quantity } else: shop_list[ingredient]['quantity'] += quantity return shop_list # test: if __name__ == "__main__": cook_book = read_cook_book("recipes.txt") result = get_shop_list_by_dishes(['Запеченный картофель', 'Омлет'], 2, cook_book) from pprint import pprint pprint(result)