1def курс_в_лева(exchange_rates):
2 new_rates = {}
3
4 for currency in exchange_rates:
5 rate = exchange_rates[currency]
6 new_rates[currency] = round(1 / rate, 4)
7
8 return new_rates
9
10
11def валута_към_левчета(*args, **rates):
12 result = {}
13
14 for currency, amount in args:
15 if currency not in result:
16 result[currency] = 0
17 result[currency] += amount
18
19 converted = []
20
21 for currency in result:
22 if currency == "BGN":
23 leva = result[currency]
24 else:
25 leva = result[currency] / rates[currency]
26
27 converted.append((currency, round(leva, 4)))
28
29 return converted
30
31
32def е_патриотична(amounts, rates):
33 total = 0
34
35 for currency, amount in amounts:
36 if currency == "BGN":
37 total += amount
38 else:
39 total += amount / rates[currency]
40
41 total = round(total, 2)
42
43 if total == int(total):
44 return "ПАТРИОТИЧНА!"
45 else:
46 return "НЕПАТРИОТИЧНА!"
..........
----------------------------------------------------------------------
Ran 10 tests in 0.000s
OK
Виктор Бечев
11.03.2026 17:20Повечето коментари, които бихме отправили към решението ти, са масови грешки или неточности. Ще коментираме на лекцията след 2 часа.
|