Skip to content

Instantly share code, notes, and snippets.

@DevinJM3
DevinJM3 / LoanPayment.py
Created November 21, 2025 20:21
Calculate monthly payment for a loan
import decimal
P = 250_000 # Principal
R = decimal.Decimal(.07125) / 12 # Divide by 12 for monthly rate
N = 30 * 12 # Multiply by 12 for months
EMI = (P * R * (1 + R)**N) / ((1 + R)**N - 1) # Equation for Estimated Monthly Payment
total_interest_paid = 0
remaining_principal = P