总付费功能

时间:2013-11-02 16:46:25

标签: python credit-card

我有这段代码:

balance = 4213
annualInterestRate = 0.2
monthlyPaymentRate = 0.04
monthly_interest_rate = annualInterestRate / 12.0
for counter in range(1, 12):
    payment = monthlyPaymentRate * balance
    monthly_unpaid_balance = balance - payment
    balance = monthly_unpaid_balance + (monthly_interest_rate * monthly_unpaid_balance)
    print('Month: {}\nMinimum monthly payment: {}\nRemaining balance:{}'.format(
              counter, round(payment, 2), round(balance, 2)))

如何计算支付总额(所有最低月支付额之和)?

2 个答案:

答案 0 :(得分:2)

我认为你只计算了11个月而不是12个月。

for counter in range(1, 12+1)

答案 1 :(得分:1)

您从my answer错误地复制粘贴。范围应该是13