如果一个人只支付信用卡公司要求的最低月供,这个程序应该在一年后计算信用卡余额。当我试着运行它时,它显示了一个语法错误,我不知道为什么。这是我的密码:
def ccb(balance, annualInterestRate, monthlyPaymentRate):
monthlyInterestRate = annualInterestRate / 12.0
month = 0
for calc in range(12):
minMonthlyPaymentRate = balance * monthlyPaymentRate
unpaidBalance = balance - minMonthlyPaymentRate
interest = monthlyInterestRate * unpaidBalance
print ("Month | Balance | Unpaid Balance | Interest")
print (month + " | " + round(balance) + " | " + round(unpaidBalance) + " | " + Interest)
balance = unpaidBalance + Interest
month += 1
print ("Remaining balance: " + round(balance))
有几件事(尽管没有一件会在评论中抛出SyntaxError——附议Andrew,如果是SyntaxError——分享完整的信息):
1)不能隐式地将整数转换为字符串,需要强制转换它。例如:
而不是
2)“利益”从未定义,但“利益”是。你知道吗
修好了,一切都好。你知道吗
而且,this可能是相关的;)
相关问题 更多 >
编程相关推荐