Python ExchangeRate API Lab Setup

Setup

Open your Terminal application and navigate to your ~/labs directory:

cd ~/labs

Make a new directory called python-exchange-rate-api-lab, then enter this directory:

mkdir python-exchange-rate-api-lab
cd python-exchange-rate-api-lab

Create a new file main.py and copy the code snippet below into the new file.

touch main.py

Before starting the lab exercise, run the following commands:

pip3 uninstall urllib3
pip3 install 'urllib3<2.0' requests

Open the contents of the directory in VSCode:

code .

Follow the instructions found in exercise to complete the Python functionality for requesting currency exchange data.

Starter Code

# Import requests package

COMMAND = ""
while COMMAND != "q":
    COMMAND = input(
        "Choose [e] to get exchange rates, or [q] to quit: ")
    if COMMAND == "e":
        target_currency = input("Enter the target currency code (ex: EUR): ").upper() amount = float(input(f"Enter the amount in {base_currency}: "))

    # Your code here