Calculating mortgage interest in Python

后端 未结 6 694
轻奢々
轻奢々 2020-12-31 17:46

I am currently learning python through a video tutorial on youtube, and have come up against a formula I cannot seem to grasp, as nothing looks right to me. The basic conc

6条回答
  •  情歌与酒
    2020-12-31 18:11

    I also came accross this problem and this is my solution

    loan = input('Enter Loan Amount: ')
    loan = float(loan)
    
    numberOfPayments = input('Enter Loan payments in years: ')
    numberOfPayments = float(numberOfPayments) * 12
    
    interest = input('Annuel interest Rate: ')
    interest = float(interest)/100/12
    
    monthlyPayments = loan * (interest * (1 + interest) ** numberOfPayments) / ((1 + interest) ** numberOfPayments - 1)
    
    print (round(monthlyPayments))
    

提交回复
热议问题