Домашни > Да върнем левчето обратно! > Решения > Решението на Коста Илев

Резултати
6 точки от тестове
0 точки от учител

6 точки общо

10 успешни теста
0 неуспешни теста
Код
Скрий всички коментари

 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

Дискусия
История

t1def курс_в_лева(exchange_rates):t1def курс_в_лева(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()}
33
4def валута_към_левчета(*args, **kwargs):4def валута_към_левчета(*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] += count9            summed_values[currency] += count
10        else:10        else:
11            summed_values[currency] = count11            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 round15            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 answer19    return answer
2020
21def е_патриотична(amount, exchange_rates):21def е_патриотична(amount, exchange_rates):
22    sum_of_currency = 022    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 "НЕПАТРИОТИЧНА!"
3131
32    32    
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op

f1def курс_в_лева(exchange_rates):f1def курс_в_лева(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()}
33
4def валута_към_левчета(*args, **kwargs):4def валута_към_левчета(*args, **kwargs):
5    answer = {}5    answer = {}
6    summed_values = {}6    summed_values = {}
n7    for id, count in args:n7    for currency, count in args:
8        if id in summed_values:8        if currency in summed_values:
9            summed_values[id] += count9            summed_values[currency] += count
10        else:10        else:
n11            summed_values[id] = countn11            summed_values[currency] = count
12    12    
n13    for id, count in summed_values.items():n13    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 round15            answer[currency] = round(count, 4) #nz dali e nujno round
16        else:16        else:
n17            answer[id] = round(count/ kwargs[id], 4)n17            answer[currency] = round(count/ kwargs[currency], 4)
18    18    
19    return answer19    return answer
2020
21def е_патриотична(amount, exchange_rates):21def е_патриотична(amount, exchange_rates):
22    sum_of_currency = 022    sum_of_currency = 0
t23    for id, count in amount:t23    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 "НЕПАТРИОТИЧНА!"
3131
32    32    
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op