| f | def курс_в_лева(exchange_rates): | f | def курс_в_лева(exchange_rates): |
| new_exchange_rates = {} | | new_exchange_rates = {} |
| | | |
| for key, value in exchange_rates.items(): | | for key, value in exchange_rates.items(): |
| n | new_exchange_rates[key] = round(1/value, 4) | n | new_exchange_rates[key] = round(1 / value, 4) |
| | | |
| return new_exchange_rates | | return new_exchange_rates |
| | | |
| def валута_към_левчета(*amount_not_exchanged, **exchange_rates): | | def валута_към_левчета(*amount_not_exchanged, **exchange_rates): |
| amount_exchanged = {} | | amount_exchanged = {} |
| | | |
| for currency, amount in amount_not_exchanged: | | for currency, amount in amount_not_exchanged: |
| if currency in amount_exchanged: | | if currency in amount_exchanged: |
| amount_exchanged[currency] += amount | | amount_exchanged[currency] += amount |
| else: | | else: |
| amount_exchanged[currency] = amount | | amount_exchanged[currency] = amount |
| | | |
| for currency, amount in amount_exchanged.items(): | | for currency, amount in amount_exchanged.items(): |
| if currency == 'BGN': | | if currency == 'BGN': |
| amount_exchanged[currency] = round(amount, 4) | | amount_exchanged[currency] = round(amount, 4) |
| else: | | else: |
| amount_exchanged[currency] = round(amount / exchange_rates[currency], 4) | | amount_exchanged[currency] = round(amount / exchange_rates[currency], 4) |
| | | |
| return list(amount_exchanged.items()) | | return list(amount_exchanged.items()) |
| | | |
| def е_патриотична(amount_not_exchanged, exchange_rates): | | def е_патриотична(amount_not_exchanged, exchange_rates): |
| total_leva = 0 | | total_leva = 0 |
| | | |
| for currency, amount in amount_not_exchanged: | | for currency, amount in amount_not_exchanged: |
| if currency == 'BGN': | | if currency == 'BGN': |
| total_leva += amount | | total_leva += amount |
| else: | | else: |
| total_leva += amount / exchange_rates[currency] | | total_leva += amount / exchange_rates[currency] |
| | | |
| total_leva = round(total_leva, 2) | | total_leva = round(total_leva, 2) |
| | | |
| if total_leva == round(total_leva): | | if total_leva == round(total_leva): |
| n | return "ПАТРИОТИЧНА!" | n | return 'ПАТРИОТИЧНА!' |
| else: | | else: |
| t | return "НЕПАТРИОТИЧНА!" | t | return 'НЕПАТРИОТИЧНА!' |