Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 复利不起作用_Python_Calculator_Python 3.6 - Fatal编程技术网

Python 复利不起作用

Python 复利不起作用,python,calculator,python-3.6,Python,Calculator,Python 3.6,这是我到目前为止所做的,我认为它是完整的,除了输出只有10000外,我没有任何错误(这是非常错误的,我用了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 i

这是我到目前为止所做的,我认为它是完整的,除了输出只有10000外,我没有任何错误(这是非常错误的,我用了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.")

正如我在评论中提到的,您的代码没有很好地捕获实际公式。正确检查支架

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.")

结果:10120.718840552334

0.08/(100.0*12)==0
<代码>/是明确的楼层划分;请参阅。将其切换为单斜杠,并且似乎有相同的错误。它的工作方式与@jornsharpe:((1+(r/(100*n)))**(n*t))所述相同。这就是答案10120.718840552334吗?你把支架弄得一团糟。尝试先计算部分,而不是整个表达式。从(1+r/n)开始。如果你把正确的方程式放在括号里,或者把括号里的东西弄乱了,用计算器来计算。啊,我发现括号里有错误。谢谢你的帮助!现在一切看起来都正常了。