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
I also watched this youtube video and had the same problem. I'm a python newbie so bear with me. The instructors in the video were using python3 and I am using python2 so I am not sure if all the syntax are the same. But using some information found in this thread and info from this link: (http://www.wikihow.com/Calculate-Mortgage-Payments) I was able to get the answer. (My calculations matched an online mortgage calculator)
#!/usr/bin/env python
# The formula I used:
M = L * ((I * ((1+I) ** n)) / ((1+I) ** n - 1))
# My code (probably not very eloquent but it worked)
# monthly payment
M = None
# loan_amount
L = None
# interest rate
I = None
# number of payments
n = None
L = raw_input("Enter loan amount: ")
L = float(L)
print(L)
I = raw_input("Enter interest rate: ")
I = float(I)/100/12
print(I)
n = raw_input("Enter number of payments: ")
n = float(n)
print(n)
M = L * ((I * ((1+I) ** n)) / ((1+I) ** n - 1))
M = str(M)
print("\n")
print("Monthly payment is " + M)