fork download
  1. LoanAmount = float(input("Enter loan amount: "))
  2. Years = float(input("Enter the number of years: "))
  3. Months = Years * 12
  4. rate = 0.05
  5. print("\n")
  6.  
  7. while rate < 0.081:
  8. print("rate: %.3f%%" % (rate * 100.0))
  9. mR = rate / 12.0
  10. MonthlyPayment = LoanAmount * (mR / (1 - (1 + mR) ** -Months))
  11. TotalPayment = MonthlyPayment * Months
  12. print("$%.2f" % (MonthlyPayment))
  13. print("$%.2f\n" % (TotalPayment))
  14. rate += 0.00125
Success #stdin #stdout 0.02s 28384KB
stdin
1000
1
stdout
Enter loan amount: Enter the number of years: 

rate: 5.000%
$85.61
$1027.29

rate: 5.125%
$85.66
$1027.98

rate: 5.250%
$85.72
$1028.67

rate: 5.375%
$85.78
$1029.35

rate: 5.500%
$85.84
$1030.04

rate: 5.625%
$85.89
$1030.73

rate: 5.750%
$85.95
$1031.42

rate: 5.875%
$86.01
$1032.11

rate: 6.000%
$86.07
$1032.80

rate: 6.125%
$86.12
$1033.49

rate: 6.250%
$86.18
$1034.18

rate: 6.375%
$86.24
$1034.87

rate: 6.500%
$86.30
$1035.56

rate: 6.625%
$86.35
$1036.25

rate: 6.750%
$86.41
$1036.94

rate: 6.875%
$86.47
$1037.63

rate: 7.000%
$86.53
$1038.32

rate: 7.125%
$86.58
$1039.01

rate: 7.250%
$86.64
$1039.70

rate: 7.375%
$86.70
$1040.40

rate: 7.500%
$86.76
$1041.09

rate: 7.625%
$86.82
$1041.78

rate: 7.750%
$86.87
$1042.47

rate: 7.875%
$86.93
$1043.17

rate: 8.000%
$86.99
$1043.86