1def курс_в_лева(exchange_rates):
2 return {currency: round(1 / value_rate, 4) for currency, value_rate in exchange_rates.items()}
3
4def валута_към_левчета(*args, **kwargs):
5 answer = {}
6 summed_values = {}
7 for currency, count in args:
8 if currency in summed_values:
9 summed_values[currency] += count
10 else:
11 summed_values[currency] = count
12
13 for currency, count in summed_values.items():
14 if currency == "BGN":
15 answer[currency] = round(count, 4) #nz dali e nujno round
16 else:
17 answer[currency] = round(count/ kwargs[currency], 4)
18
19 return answer
20
21def е_патриотична(amount, exchange_rates):
22 sum_of_currency = 0
23 for currency, count in amount:
24 sum_of_currency += count / exchange_rates[currency]
25
26 sum_of_currency = round(sum_of_currency, 2)
27 if sum_of_currency == int(sum_of_currency):
28 return "ПАТРИОТИЧНА!"
29 else:
30 return "НЕПАТРИОТИЧНА!"
31
32
..........
----------------------------------------------------------------------
Ran 10 tests in 0.000s
OK
| t | 1 | def курс_в_лева(exchange_rates): | t | 1 | def курс_в_лева(exchange_rates): |
| 2 | return {currency: round(1 / value_rate, 4) for currency, value_rate in exchange_rates.items()} | 2 | return {currency: round(1 / value_rate, 4) for currency, value_rate in exchange_rates.items()} | ||
| 3 | 3 | ||||
| 4 | def валута_към_левчета(*args, **kwargs): | 4 | def валута_към_левчета(*args, **kwargs): | ||
| 5 | answer = {} | 5 | answer = {} | ||
| 6 | summed_values = {} | 6 | summed_values = {} | ||
| 7 | for currency, count in args: | 7 | for currency, count in args: | ||
| 8 | if currency in summed_values: | 8 | if currency in summed_values: | ||
| 9 | summed_values[currency] += count | 9 | summed_values[currency] += count | ||
| 10 | else: | 10 | else: | ||
| 11 | summed_values[currency] = count | 11 | summed_values[currency] = count | ||
| 12 | 12 | ||||
| 13 | for currency, count in summed_values.items(): | 13 | for currency, count in summed_values.items(): | ||
| 14 | if currency == "BGN": | 14 | if currency == "BGN": | ||
| 15 | answer[currency] = round(count, 4) #nz dali e nujno round | 15 | answer[currency] = round(count, 4) #nz dali e nujno round | ||
| 16 | else: | 16 | else: | ||
| 17 | answer[currency] = round(count/ kwargs[currency], 4) | 17 | answer[currency] = round(count/ kwargs[currency], 4) | ||
| 18 | 18 | ||||
| 19 | return answer | 19 | return answer | ||
| 20 | 20 | ||||
| 21 | def е_патриотична(amount, exchange_rates): | 21 | def е_патриотична(amount, exchange_rates): | ||
| 22 | sum_of_currency = 0 | 22 | sum_of_currency = 0 | ||
| 23 | for currency, count in amount: | 23 | for currency, count in amount: | ||
| 24 | sum_of_currency += count / exchange_rates[currency] | 24 | sum_of_currency += count / exchange_rates[currency] | ||
| 25 | 25 | ||||
| 26 | sum_of_currency = round(sum_of_currency, 2) | 26 | sum_of_currency = round(sum_of_currency, 2) | ||
| 27 | if sum_of_currency == int(sum_of_currency): | 27 | if sum_of_currency == int(sum_of_currency): | ||
| 28 | return "ПАТРИОТИЧНА!" | 28 | return "ПАТРИОТИЧНА!" | ||
| 29 | else: | 29 | else: | ||
| 30 | return "НЕПАТРИОТИЧНА!" | 30 | return "НЕПАТРИОТИЧНА!" | ||
| 31 | 31 | ||||
| 32 | 32 |
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||
| f | 1 | def курс_в_лева(exchange_rates): | f | 1 | def курс_в_лева(exchange_rates): |
| 2 | return {currency: round(1 / value_rate, 4) for currency, value_rate in exchange_rates.items()} | 2 | return {currency: round(1 / value_rate, 4) for currency, value_rate in exchange_rates.items()} | ||
| 3 | 3 | ||||
| 4 | def валута_към_левчета(*args, **kwargs): | 4 | def валута_към_левчета(*args, **kwargs): | ||
| 5 | answer = {} | 5 | answer = {} | ||
| 6 | summed_values = {} | 6 | summed_values = {} | ||
| n | 7 | for id, count in args: | n | 7 | for currency, count in args: |
| 8 | if id in summed_values: | 8 | if currency in summed_values: | ||
| 9 | summed_values[id] += count | 9 | summed_values[currency] += count | ||
| 10 | else: | 10 | else: | ||
| n | 11 | summed_values[id] = count | n | 11 | summed_values[currency] = count |
| 12 | 12 | ||||
| n | 13 | for id, count in summed_values.items(): | n | 13 | for currency, count in summed_values.items(): |
| 14 | if id == "BGN": | 14 | if currency == "BGN": | ||
| 15 | answer[id] = round(count, 4) #nz dali e nujno round | 15 | answer[currency] = round(count, 4) #nz dali e nujno round | ||
| 16 | else: | 16 | else: | ||
| n | 17 | answer[id] = round(count/ kwargs[id], 4) | n | 17 | answer[currency] = round(count/ kwargs[currency], 4) |
| 18 | 18 | ||||
| 19 | return answer | 19 | return answer | ||
| 20 | 20 | ||||
| 21 | def е_патриотична(amount, exchange_rates): | 21 | def е_патриотична(amount, exchange_rates): | ||
| 22 | sum_of_currency = 0 | 22 | sum_of_currency = 0 | ||
| t | 23 | for id, count in amount: | t | 23 | for currency, count in amount: |
| 24 | sum_of_currency += count / exchange_rates[id] | 24 | sum_of_currency += count / exchange_rates[currency] | ||
| 25 | 25 | ||||
| 26 | sum_of_currency = round(sum_of_currency, 2) | 26 | sum_of_currency = round(sum_of_currency, 2) | ||
| 27 | if sum_of_currency == int(sum_of_currency): | 27 | if sum_of_currency == int(sum_of_currency): | ||
| 28 | return "ПАТРИОТИЧНА!" | 28 | return "ПАТРИОТИЧНА!" | ||
| 29 | else: | 29 | else: | ||
| 30 | return "НЕПАТРИОТИЧНА!" | 30 | return "НЕПАТРИОТИЧНА!" | ||
| 31 | 31 | ||||
| 32 | 32 |
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||
11.03.2026 08:40