Currency Converter with Python Homework Solution

Currency Change between USD, CAD, GBP and MXP

The project is to make a currency converter with the help of Python. You have to make a basic currency converter with the help of Python, which will include USD, Canadian dollar, British pound, and Mexican Peso.

Solution:

``` amount = int(input("Enter amount:")) values = {'USD': 1.00, 'Pound': 1.40, 'CAD': 0.81, 'Peso': 0.05} while True: currencytype = input("Enter currency type, options: USD/CAD/Pound/Peso ") if currencytype in ['USD', 'CAD', 'Pound', 'Peso']: break else: print('Please enter correct currency type. options: USD/CAD/Pound/Peso ') while True: totype = input("Enter the currency type you want to convert to, option: USD/CAD/Pound/Peso ") if totype in ['USD', 'CAD', 'Pound', 'Peso']: break else: print('Please enter correct currency type. options: USD/CAD/Pound/Peso ') newamount = amount * values[currencytype]/values[totype] print('Convert to: {:.2f} {}'.format(newamount, totype)) ```

Screenshot: