Python复合兴趣不起作用

时间:2018-06-28 21:11:32

标签: python calculator python-3.6

这是我到目前为止的内容,我认为它是完整的,除了输出仅为10,000的事实外,我的错误为零(这是错误的,我使用15年作为“ t”)。我环顾了类似的问题,并遵循了一些建议,但没有任何解决方法。我只想念些愚蠢的东西吗?谢谢!

print ("Hello, this program will calculate compound interest with a rate of 8%, a principal of 10,000 dollars, on a 12 month cycle (where n is 12)")
p = 10000.00
r = .08
n = 12
t = int(input("Please enter the length of time for the interest to be compounded: "))
amount = (p*(1+(r//(100.0*n))**(n*t)))
print ("The final amount is",amount,"for an initial investment of 10,000, with a rate of 8% and compounded monthly over",t,"years.")

1 个答案:

答案 0 :(得分:1)

正如我的评论中所述,您的代码无法很好地捕获实际公式。正确检查支架。

print ("Hello, this program will calculate compound interest with a rate of 8%, a     principal of 10,000 dollars, on a 12 month cycle (where n is 12)")
p = 10000.00
r = .08
n = 12
t = int(input("Please enter the length of time for the interest to be compounded: "))
amount = p*((1+(r/(100*n)))**(n*t))
print ("The final amount is",amount,"for an initial investment of 10,000, with a rate of 8% and compounded monthly over",t,"years.")

结果:1​​0120.718840552334

相关问题