This Python program converts currency exchange rates into Polish zlotys (PLN) according to the average exchange rates from Table A of the National Bank of Poland on a selected day (beginning from 2002-01-02).
The purpose of the program is to use an external API (Application Programming Interface) to convert exchange rates based on the data provided by the user. Thanks to this project, I learned how to use APIs and apply them to my another programming projects.
- Python - version 3.9.13
- Python third-party packages:
- requests - version 2.29.0
- python-dateutil - version 2.8.2
- NBP Web API
- The user can provide up to two arguments (date and three-letter currency code) when running the program.
- The program can also be run with one argument or none. It doesn't matter what user entered - the date or the currency code.
- If the user does not enter any data when starting the program, the program will ask for it itself.
- Date can be entered in any way, for example: 13.12.2011, "15 May 2015" or 2016-06-16, or even 20091209.
Note that the date with spaces must be entered in "quotation marks".
I assume you know how to cloning this repository. If not, I refer you to this publication.
At the beginning You need to make sure you have Python version up to 3.9, as one of the packages does not work with the latest versions of Python.
If You don't have any Python version, download and install from here.
To verify Python version, type in terminal:
$ python --version
If You are seeing this answer (* - any digits):
$ python --version
$ Python 3.9.*
We are at home! Now You need to install virtual environment like this:
$ python -m venv venv
$ cd venv\Scripts
$ activate
$ cd ..
$ cd ..
and install dependencies in the previously created virtual environment:
$ pip install -r requirements.txt
After installing this, run the program like bellow.
How does one go about using it? It's simple. To run program without any arguments type in terminal:
$ python currency-exchange.py
or to run program with GBP currency code for example as one of arguments:
$ python currency-exchange.py gbp
or to run program with two arguments (date and currency code):
$ python currency-exchange.py 20.11.2019 usd
- This program was inspired by one of exercises of the Practical Python educational program.
- Many thanks to Krzysztof Mędrela.