我是靠谱客的博主 自由汽车,这篇文章主要介绍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))

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

最后

以上就是自由汽车最近收集整理的关于pythonfor循环怎么改_如何在python中更改for循环中的变量?的全部内容,更多相关pythonfor循环怎么改_如何在python中更改for循环中内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(115)

评论列表共有 0 条评论

立即
投稿
返回
顶部