1from collections import defaultdict
2from functools import reduce
3
4def курс_в_лева(ex_rates):
5 return {currency: round(1/rate, 4) for currency, rate in ex_rates.items()}
6
7def валута_към_левчета(*currencies, **ex_rates):
8 result = defaultdict(float)
9 for type, amount in currencies:
10 if type == 'BGN':
11 result[type] += amount
12 else:
13 result[type] += amount / ex_rates[type]
14 return {currency: round(amount, 4) for currency, amount in result.items()}
15
16def е_патриотична(amounts, ex_rates):
17 amount_in_bgn = reduce(lambda x, y: x + y, [value / ex_rates[type] for type, value in amounts])
18 return "ПАТРИОТИЧНА!" if round(amount_in_bgn*1000, 0) == round(amount_in_bgn, 2) * 1000 else "НЕПАТРИОТИЧНА!"
......FF..
======================================================================
FAIL: test_е_патриотична_стотинки (test.TestЕПатриотична.test_е_патриотична_стотинки)
The total should be evaluated with a precision of 2 digits after the decimal point.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 132, in test_е_патриотична_стотинки
self.assertEqual("ПАТРИОТИЧНА!", патриотична)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'ПАТРИОТИЧНА!' != 'НЕПАТРИОТИЧНА!'
- ПАТРИОТИЧНА!
+ НЕПАТРИОТИЧНА!
? ++
======================================================================
FAIL: test_е_патриотична_цели (test.TestЕПатриотична.test_е_патриотична_цели)
The total should be evaluated by means of whether the sum is a round number.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 124, in test_е_патриотична_цели
self.assertEqual("НЕПАТРИОТИЧНА!", непатриотична)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'НЕПАТРИОТИЧНА!' != 'ПАТРИОТИЧНА!'
- НЕПАТРИОТИЧНА!
? --
+ ПАТРИОТИЧНА!
----------------------------------------------------------------------
Ran 10 tests in 0.001s
FAILED (failures=2)
09.03.2026 22:24
09.03.2026 22:25