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