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))

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值