pythonfor循环怎么改_如何在python中更改for循环中的变量?

程序必须要求用户提供起始变量:起始余额、年利率和最低月供。

这是我的密码。在initialOutstandingBalance= float(raw_input('What is the outstanding balance on your

card?'))

annualInterestRate=float(raw_input('What is the annual interest rate expressed as a

decimal?'))

minimumMonthlyPaymentRate=float(raw_input('What is the minimum monthly payment rate on

your card expressed as a decimal?'))

for month in range(1,13):

print("Month: "+ str(month))

minimumMonthlyPayment=float(minimumMonthlyPaymentRate*initialOutstandingBalance)

interestPaid=float((annualInterestRate)/(12*initialOutstandingBalance))

principalPaid=float(minimumMonthlyPayment-interestPaid)

newBalance=float(initialOutstandingBalance-principalPaid)

print("Minimum monthly payment: $"+str(minimumMonthlyPayment))

print("Principle paid: $"+str(principalPaid))

print("Remaining Balance: $"+str(newBalance))

如何使剩余余额正确更新?我不知道如何在每个月底更新余额。到目前为止,每个月返回的最小月供、已付本金和剩余余额的值相同。在

你可能感兴趣的:(pythonfor循环怎么改)