TVM Solver: Time Value of Money Solver. Solves for PMT, FV, PV, or N. Run tvm() or press the var button and select tvm(). Select the variable to solve for, and the inputs are similar to the TI calculators.
from math import * def tvm(): print("Select variable to solve:") print("1:PMT 2:FV 3:PV 4:N") solv=int(input("?")) if solv != 4: N=int(input(" N= ")) r=float(input(" I%= ")) if solv != 3: pv=float(input(" PV= ")) if solv != 1: pmt=float(input("PMT= ")) if solv != 2: fv=float(input(" FV= ")) ppy=int(input("P/Y= ")) if r > 1: r=r/100 if solv == 1: pmt=-r/ppy*(fv+pv*(1+r/ppy)**N)/((1+r/ppy)**N-1) print("") print("Periodic Payment:") print("pmt=",pmt) if solv == 2: fv=(ppy*pmt-ppy*pmt*(1+r/ppy)**N-pv*r*(1+r/ppy)**N)/r print("") print("Future Value:") print("FV=",fv) if solv == 3: pv=((1+r/ppy)**(-N)*(ppy*pmt-fv*r-ppy*pmt*(1+r/ppy)**N)/r) print("") print("Present Value:") print("PV=",pv) if solv == 4: N=log((ppy*pmt-fv*r)/(ppy*pmt+pv*r))/log(1+r/ppy) print("") print("Number of Payments:") print("N=",N)