From 3b7d5d6f6e038bf6d78c57ccc85017e295812f6f Mon Sep 17 00:00:00 2001 From: Ardor Date: Thu, 7 May 2026 13:18:36 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F=20fin?= =?UTF-8?q?d=5Fmost=5Fexpensive=5Fitem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zadanie_1.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/zadanie_1.py b/zadanie_1.py index 7b66bdb..7b6e40a 100644 --- a/zadanie_1.py +++ b/zadanie_1.py @@ -65,4 +65,15 @@ def calculate_user_total(user_orders: list[dict]) -> float: """ Суммирует все значения 'total' для одного пользователя. """ - return sum(order['total'] for order in user_orders) \ No newline at end of file + return sum(order['total'] for order in user_orders) + + +# 5. Поиск самого дорогого товара (по цене за единицу) +def find_most_expensive_item(orders: list[dict]) -> tuple[str, float]: + """ + Возвращает (название, цена) товара с максимальной price. + """ + if not orders: + return ('', 0.0) + most_expensive = max(orders, key=lambda x: x['price']) + return (most_expensive['item_name'], most_expensive['price']) \ No newline at end of file