用Python偿还信用卡债务代码

2024-05-15 13:35:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我很难编写一个程序来计算12个月后信用卡债务的余额。这是我目前所拥有的,但是当我运行程序时,是说“名称RBm未定义”。在

x = float(raw_input('What is the outstanding balance on the credit card?'))
y = float(raw_input('What is the annual interest rate?'))
z = float(raw_input('What is the minimum monthly payment rate?'))
for n in range(1, 13):
    m = n-1
    RB0 = x
    MMPn = RBm*z
    IP = (y/12)*x
    PPn = MMPn - IP
    RBn = RBm - PPn
    print 'Month:', n
    print 'Minimum Monthly Payment:', MMPn
    print 'Principal Paid:', PPn
    print 'Remaining Balance:', RBn

每月支付本金,剩余利息为每月支付,剩余利息为每月支付。 我想出了这个方法,我可以用不同的数字复制粘贴12次,但是我希望它更高效,所以我想出了上面的代码。在

^{pr2}$

Tags: the程序ipinputrawrateisfloat