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