/
Alex_Ural
/
PYAPI_Homework
Обзор
Документация
Войти
/
Alex_Ural
/
PYAPI_Homework
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
PYAPI_Task1.py
25 строк
846 B
Alex_Ural
create: PYAPI_Task1.py
21 апр 2026, 16:15
Верифицирован
21 апр 2026, 16:15
c134c2d
Код
Авторство
О чём код?
cocktail_recipes = {} with open('cocktails.txt', 'r', encoding='utf-8') as f: for line in f: recipe_name = line.strip() if not recipe_name: continue count = int(next(f).strip()) ingredients = [] for _ in range(count): ing_line = next(f).strip() name, qty, measure = [part.strip() for part in ing_line.split('|')] ingredients.append({'ingredient_name': name, 'quantity': float(qty), 'measure': measure}) cocktail_recipes[recipe_name] = ingredients # === Тест для Задания №1 === print(f"Маргарита:") for ing in cocktail_recipes['Маргарита']: print(f" - {ing['ingredient_name']}: {ing['quantity']} {ing['measure']}")