python复利代码_python复利

我在想办法让这些年的利息和本金正确地显示出来。以下是我遇到问题的代码部分:print ('Luke\n-----')

print ('Year\tPrincipal\tInterest\t Total')

LU_RATE = .05

YEAR = 1

Principal = 100

for YEAR in range (1,28):

# Calculating Luke's total using formula for compounding interest

Lu_Total = (Principal * ((1 + LU_RATE) ** YEAR))

# I realize it's a logical error occurring somewhere here

Lu_Interest = #I'm not sure what to code here

Lu_Principal = #And here

# Displaying the Principal, Interest, and Total over the 27

print (YEAR,'\t%.02f\t\t %.02f\t\t %.02f' %(Lu_Principal, Lu_Interest, Lu_Total))

以下是显示的内容(当然不包括注释符号):

^{pr2}$

我试着编写的每一个等式在第一年都有正确的利息,但最后却把本金作为总额。过去的每一年都计算出错误的数字。在

它应该看起来像:Luke

-----

Year Principal Interest Total

1 100.00 5.00 105.00

2 105.00 5.25 110.25

3 110.25 5.51 115.76

#etc etc....

我一整天都在断断续续地工作,只是好像搞不懂。提前感谢您的任何帮助或建议。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值