python求年利率_python-3.x - 如何在python 3中计算年利率 - SO中文参考 - www.soinside.com...

这是代码:P = int(input("Enter starting principle please.\n"))

n = int(input("Enter Compound interest rate.(daily, monthly, quarterly,half-year, yearly)\n"))

r = float(input("Enter annual interest amount. (decimal)\n"))

t = int(input("Enter the amount of years.\n"))

t = 1

while t-1 <= 5-1 :

final = P * (((1 + (r/n)) ** (n*t)))

t += 1

print ("The final amount after", round(t-1), "years is", round(final,2))

当我尝试输入时:

1000

1

0.02

2

结果将是这样:

请输入开始原则。

输入复合利率。(每日,每月,每季度,半年,每年)

输入年度利息金额。 (十进制)

输入年份。

1年后的最终金额是1020.0

两年后的最终金额是1040.4

三年后的最终金额为1061.21

四年后的最终金额是1082.43

5年后的最终金额为1104.08

问题是,它不会返回到要求的输入年份(例如,当我尝试输入2年时,它将最多显示5年)]]

这是代码:P = int(input(“请输入起始原则。\ n”))n = int(input(“请输入复合利率。(每日,每月,每季度,半年,每年)\ n “))r = float(input(”输入年鉴...

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值