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 валута_към_левчета(*amounts, **exchange_rates):
8 sums = {}
9 for currency, amount in amounts:
10 if currency not in sums:
11 sums[currency] = 0
12 sums[currency] += amount
13 result = []
14 for currency, amount in sums.items():
15 if currency == "BGN":
16 levs = round(amount, 4)
17 else:
18 levs = round(amount / exchange_rates[currency], 4)
19 result.append((currency, levs))
20 return result
21
22def е_патриотична(amounts, exchange_rates):
23 total = 0
24 for currency, amount in amounts:
25 total += amount / exchange_rates[currency]
26 total = round(total, 2)
27 if total == round(total):
28 return "ПАТРИОТИЧНА!"
29 return "НЕПАТРИОТИЧНА!"
..........
----------------------------------------------------------------------
Ran 10 tests in 0.000s
OK
Виктор Бечев
11.03.2026 16:24Решението е сравнително чисто, проблемите, от които малко страда са масови и ще ги дискутираме на лекцията след малко.
|