python---利息计算

annualinterestrate=eval(input("Enter annual interest rate,e.g.,7.25:"))
monthlyinterestrate=annualinterestrate/1200
numberofyears=eval(input("enter number of years as  an integer,e.g.,5:"))
loanamount=eval(input("Enter loan number:"))
monthlypayment=loanamount*monthlyinterestrate/(1-1/(1+monthlyinterestrate)**(numberofyears*12))
totalpayment=monthlypayment*numberofyears*12
print("the monthly payment is",int(monthlypayment*100)/100)
print("the total payment is",int(totalpayment*100)/100)


你可能感兴趣的:(Python入门)