Untitled

 avatar
unknown
plain_text
2 years ago
1.1 kB
7
Indexable
#EXE3_#Imagine that the warehouse also buys from suppliers 
#outside the euro zone, so it will buy in currency other 
#than EUR, so we need a function that converts that given 
#price from <> EUR to EUR, so that our warehouse always 
#has all products in EUR (insert 4/5 currencies other than 
#EUR of your choice). 
#Update previous function (ex.1) accordingly
# I use USD= united states dollar, JPY= Japanese yen, CAD= Canadian dollar, SEK: Swedish Krona

def convert_to_eur(price, currency):
    if currency == 'EUR':
        return price
    elif currency == 'USD':
        return price * 0.85
    elif currency == 'CAD':
        return price * 0.68
    elif currency == 'JPY':
        return price * 0.0078
    elif currency == 'SEK':
        return price * 0.10
    else:
        raise ValueError('Unsupported currency')

price = float(input('Enter a price: '))
currency = input('Enter a currency (USD, GBP, JPY, AUD, or EUR): ')

eur_price = convert_to_eur(price, currency)

print(f'{price:.2f} {currency} = {eur_price:.2f} EUR')
Editor is loading...