/
sejeenn
/
python_basic
Обзор
Документация
Войти
/
sejeenn
/
python_basic
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Module19/04_goods/main.py
34 строки
845 B
Eugene Vorontsov
Copy repo python basic
03 фев 2025, 20:23
03 фев 2025, 20:23
a8fce4a
Код
Авторство
О чём код?
goods = { 'Лампа': '12345', 'Стол': '23456', 'Диван': '34567', 'Стул': '45678', } store = { '12345': [ {'quantity': 27, 'price': 42}, ], '23456': [ {'quantity': 22, 'price': 510}, {'quantity': 32, 'price': 520}, ], '34567': [ {'quantity': 2, 'price': 1200}, {'quantity': 1, 'price': 1150}, ], '45678': [ {'quantity': 50, 'price': 100}, {'quantity': 12, 'price': 95}, {'quantity': 43, 'price': 97}, ], } print() for title in goods: code = goods.get(title) total_cost = 0 total_quantity = 0 for i_g in store[code]: total_cost += i_g['quantity'] * i_g['price'] total_quantity += i_g['quantity'] print(title, '-', total_quantity, 'шт, стоимость:', total_cost, 'руб')