balance=4213
monthlyPaymentRate=0.04
annualInterestRate=0.2
Month=1
monthRate=annualInterestRate/12.0
sum=0
for i in range(1,13):
sum=sum+balance*monthlyPaymentRate
print 'Month: ',i
print('Minimum monthly payment: %.2f'%(balance*monthlyPaymentRate))
balance=balance-balance*monthlyPaymentRate
balance=balance+monthRate*balance
print('Remaining balance: %.2f'%balance)
print('Total paid: %.2f'%sum)
print('Remaining balance: %.2f'%balance)
题目要求计算一年之后还应该交多少钱,这一年一共交了多少钱。学到的知识点是:知道怎么讲小数点后两位输出了
print('%.2f'%float)