TVM Solver with balance
from math import * def tvm(): print("Select variable to solve:") print("1:PMT 2:FV 3:PV 4:N 5:bal") solv=int(input("?")) if (solv != 4) and (solv !=5): 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) and (solv !=5): fv=float(input(" FV= ")) ppy=int(input("P/Y= ")) if solv == 5: m=int(input("pmt# = ")) 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) if solv == 5: bal=pv*(1+r/ppy)**m + pmt*((1+r/ppy)**m-1)/(r/ppy) print("") print("Balance after",m,"payments:") print("bal=",bal)