借了10000,每个月利息0.1,一年后连本带息还清,用python循环while语句写
时间: 2024-05-29 16:11:58 浏览: 116
balance = 10000
interest_rate = 0.1
months = 0
while balance > 0:
months += 1
interest = balance * interest_rate / 12
balance += interest
balance -= 10000 / 12 #每个月还本
print("共用了", months, "个月还清借款。")
相关问题
借了10000,每个月利息0.1,一年后连本带息还清,用python循环语句写
money = 10000 # 初始借款金额
interest_rate = 0.1 # 每月利息
months = 12 # 还款月数
for i in range(1, months+1):
interest = money * interest_rate # 计算利息
money += interest # 加上利息
print("第{}个月,利息为{}元,本月还款{}元,剩余欠款{}元".format(i, round(interest, 2), round((money/months), 2), round(money - (money/months)*i, 2)))
print("一年后连本带息共还款{}元".format(money))
借了10000,每个月利息0.1,一年后连本带息还清,用python写
principal = 10000
interest_rate = 0.1
months = 12
total_interest = principal * interest_rate * months
total_payment = principal + total_interest
print("借了{}元,每个月利息{},一年后连本带息共还{}元".format(principal, interest_rate, total_payment))
阅读全文