Learn practical skills, build real-world projects, and advance your career
Updated 2 years ago
Real problems:
(1) Radha is planning to buy a house that costs $1,260,000. She considering two options to finance her purchase:
Option 1: Make an immediate down payment of $300,000, and take loan 8-year loan with an interest rate of 10% (compounded monthly) for the remaining amount.
Option 2: Take a 10-year loan with an interest rate of 8% (compounded monthly) for the entire amount.
Both these loans have to be paid back in equal monthly installments (EMIs). Which loan has a lower EMI among the two?
import math
def loan_emi(amount, duration, rate, down_payment=0):
loan_amount = amount - down_payment
emi = loan_amount * rate *((1+rate)**duration / (((1+rate)**duration)-1))
emi = math.ceil(emi)
return emi
emi_1 = loan_emi(amount=1260000,
duration=8*12,
rate=0.1/12,
down_payment=300000
)
emi_2 = loan_emi(amount=1260000,
duration=10*12,
rate=0.08/12)