Day 30 of 100 Days Coding Challenge: Python
Back in university, I survived a finance course where one of the big thrills was figuring out how much you’d owe on a mortgage—because nothing says fun like watching compound interest quietly ruin your weekend. We used financial calculators that looked like relics from a Cold War museum, and if the professor was feeling futuristic, we’d get to use Excel. These days, of course, you can find slick EMI calculators on almost every bank’s website. But today I wondered—could I make one myself? Turns out, yes. I built a simple Python EMI calculator app. It’s not glamorous, it doesn’t sparkle, and it definitely won’t win UX awards, but it works. No spreadsheets. No arcane formulas. Just pure, functional code—and the oddly satisfying thrill of watching your hypothetical loan turn into very real monthly heartbreak.
Today’s Motivation / Challenge
Ever tried to figure out how much you’re actually paying the bank for that “affordable” loan? Spoiler: it’s more than you think. Today’s challenge was a practical one—create a loan/EMI calculator to see the real cost of borrowed money. It’s part nostalgia (throwback to finance class) and part grown-up reality check. Plus, building this in Python and Streamlit let me stretch some GUI/web muscles without losing my mind.
Purpose of the Code (Object)
This code calculates your monthly loan payment (EMI), the total amount you’ll pay back, and how much of that is interest. You just punch in the loan amount, interest rate, and loan period. It does the math, so you don’t have to reach for that dusty calculator—or guess wildly.
AI Prompt:
Create a loan/EMI calculator in Python that asks for principal, interest rate, and tenure, then calculates and displays the monthly EMI, total repayment, and total interest. Include both a Streamlit app and a Tkinter GUI.
Functions & Features
- Takes user input for loan amount, interest rate, and tenure
- Calculates monthly EMI using a standard financial formula
- Displays total repayment and total interest
- Offers both a desktop GUI and a Streamlit web app interface
Requirements / Setup
pip install streamlit
For GUI:
- Built-in tkinter (no install required on most Python versions)
Minimal Code Sample
emi = (P * r * (1 + r)**n) / ((1 + r)**n – 1)
This formula calculates your monthly payment using principal (P), monthly interest rate (r), and loan term in months (n).
Notes / Lessons Learned
The code wasn’t hard to write. What tripped me up? Forgetting I wasn’t in Python 101 anymore—I was in Streamlit land. So when I ran it the usual way (python scriptname.py), nothing happened. No errors. Just silence. A tumbleweed moment. Then I remembered: it’s streamlit run scriptname.py. Once I got that right, the app popped open in my browser like a well-behaved web butler. Lesson learned: the right tool needs the right doorbell.
Optional Ideas for Expansion
- Add a pie chart showing principal vs. interest breakdown
- Allow users to export results as a CSV or PDF
- Include an “extra payment” option to see how prepayments affect the loan term
