早上好,我已经很久没有玩python了,我似乎忘记了一点
我正在尝试制作一个还款信用卡还款计算器,我已经让它工作了,但我正在努力改进它。目前它的工作,如果我填写一个付款金额,这将告诉我需要多长时间才能支付,但我想填写的付款数量,然后告诉我需要支付多少。这是我的密码,有人能告诉我正确的方向吗
original_amount = amount = 500
repayment = 1
interest = 30.34
total_interest = 0
number_of_payments = 8
def calculate_interest(old_balance):
global interest
global monthly_interest
global total_interest
monthly_interest_percent = interest / 100 / 12
monthly_interest = old_balance * monthly_interest_percent
new_balance = old_balance + monthly_interest
total_interest += monthly_interest
return new_balance
count = 0
while amount > 0:
card_value = calculate_interest(amount)
amount = card_value - repayment
count += 1
if count > number_of_payments:
repayment += 1
我认为你的问题是:
还款是你要偿还的金额,但我不认为这是你想要增加的,你可能想要增加付款的数量
相关问题 更多 >
编程相关推荐