Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
dictionary_price = {} dictionary_quantity = {} while True: line = input() if line == "buy": break line_split = line.split() product = line_split[0] price = float(line_split[1]) quantity = int(line_split[2]) if product not in dictionary_price: # Ако продуктът НЕ Е в първия или във втория речник!!! dictionary_price[product] = price # Добавяме единичната цена към речника за цените dictionary_quantity[product] = quantity # Добавяме количеството къ, речника за количеството else: dictionary_price[product] = price # Обновява се цената dictionary_quantity[product] += quantity for product in dictionary_price: price = dictionary_price[product] quantity = dictionary_quantity[product] total_price = price * quantity print(f"{product} -> {total_price:.2f}")
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)