Интерес Python Compound не работает - PullRequest
0 голосов
/ 29 июня 2018

Вот то, что у меня пока есть, я думаю, что оно завершено, и у меня ноль ошибок, за исключением того факта, что выход составляет всего 10 000 (что неправильно, я использовал 15 лет как «т»). Я посмотрел вокруг на подобные вопросы и следовал нескольким из предложений, но ничто не исправило это. Я просто скучаю по чему-то глупому? Спасибо!

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 голосов
/ 29 июня 2018

Как уже упоминалось в моем комментарии, ваш код не очень хорошо отражает фактическую формулу. Проверьте правильность скобок.

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

...