1def курс_в_лева(exchange_rates):
2 return {
3 currency: round(1 / rate, 4)
4 for currency, rate in exchange_rates.items()
5 }
6"""
7exchange_rates = {"EUR": 1.9558, "USD": 1.6718, "DKK": 0.2616}
8print(курс_в_лева(exchange_rates))
9"""
10
11def валута_към_левчета(*args, **rates):
12 totals = {}
13
14 for currency, amount in args:
15 totals[currency] =totals.get(currency, 0) + amount
16
17 result = []
18
19 for currency, total_amount in totals.items():
20 if currency =="BGN":
21 leva = total_amount
22 else:
23 leva = total_amount / rates[currency]
24
25 result.append((currency, round(leva, 4)))
26
27 return result
28
29"""
30print(валута_към_левчета(
31 ("EUR", 1.5),
32 ("USD", 10),
33 ("DKK", 10),
34 ("EUR", 2.5),
35 EUR=0.5,
36 USD=0.8,
37 DKK=7,
38))
39
40print(валута_към_левчета(
41 ("BGN", 1.5),
42 ("USD", 10),
43 USD=0.8,
44))
45"""
46
47def е_патриотична(amounts, exchange_rates):
48 total_leva = 0
49
50 for currency, value in amounts:
51 total_leva += value / exchange_rates[currency]
52
53 total_leva =round(total_leva, 2)
54
55 if total_leva.is_integer():
56 return "ПАТРИОТИЧНА!"
57 else:
58 return "НЕПАТРИОТИЧНА!"
59
60"""
61exchange_rates = {"EUR": 0.5, "USD": 0.6, "DKK": 3.8}
62
63amount = [("EUR", 1), ("USD", 3), ("DKK", 7.6), ("EUR", 3)]
64print(е_патриотична(amount, exchange_rates))
65
66amount = [("EUR", 1), ("USD", 2), ("DKK", 7.6), ("EUR", 3)]
67print(е_патриотична(amount, exchange_rates))
68"""
..........
----------------------------------------------------------------------
Ran 10 tests in 0.000s
OK
06.03.2026 16:26
06.03.2026 16:25
06.03.2026 16:27