Day 35 of 100 Days Coding Challenge: Python
As an accountant, I sometimes find myself wrangling with currencies like the Euro or the Yen—especially when it’s time to pay international vendors. Sure, I could just hop over to a bank’s website to check the latest rate and be done with it. But where’s the fun in that? There’s something satisfying about making a mini tool that does the fetching for you. It’s like teaching your computer to do the boring part while you sip coffee and pretend you’re working very hard. Besides, who wouldn’t want their own personal exchange rate butler?
Today’s Motivation / Challenge
Today’s project was all about merging curiosity with practicality. Currency converters might not sound glamorous, but they’re surprisingly useful—and they offer the perfect excuse to explore how APIs work in the wild. Plus, if you’ve ever had to double-check if you’re about to overpay a vendor in yen, you’ll understand the thrill of watching your own Python script spit out the answer faster than your bank’s clunky interface ever could.
Purpose of the Code (Object)
This script fetches real-time exchange rates and converts any amount between two currencies. Instead of trusting your memory or the whims of Google, you can just run this quick script and let it do the math. It’s lightweight, no fuss, and runs right in your terminal.
AI Prompt:
Convert currency between any two valid codes using live data. Keep it light. No API keys, no hassle.
Functions & Features
- Converts between any two standard currency codes (e.g., USD to JPY)
- Fetches live exchange rates from a free public API
- Displays the converted amount in real time
- Includes error handling for invalid codes or bad input
Requirements / Setup
You’ll need:
pip install requests
Works with: Python 3.x
Minimal Code Sample
url = f”https://open.er-api.com/v6/latest/{from_currency.upper()}”
response = requests.get(url)
rate = response.json()[“rates”].get(to_currency.upper())
converted = amount * rate
This fetches the latest rates and calculates the converted amount.
Notes / Lessons Learned
This program did not go down without a fight. There are two main ways to fetch real-time exchange rates:
Option 1 is using https://api.exchangerate.host/convert, which is free and doesn’t need an API key. It sounded perfect. I plugged in the URL, hit run, and got… nothing. After far too much debugging, I realized the problem wasn’t the code—it was that something on my system was redirecting that link to exchangeratesapi.io, a completely different API that demands an API key. DNS goblins? Old environment settings? Ghosts of APIs past? Who knows.
So, I switched to a new free option: https://open.er-api.com. No signup, no key, and it worked like a charm. The moral of the story? Sometimes the easiest-looking door is secretly locked, and the best path forward is just to find a different door. Preferably one that doesn’t ask for your email address.
Optional Ideas for Expansion
- Add a list of common currency codes for reference
- Let users select currencies from a simple dropdown in a GUI version
- Track historical exchange rates for past transactions

