python - Can't calculate compound interest correctly -


here code:

def calculate(*args): try:     value = float(income.get())     expenses.set("$"+str(value * .60))     longterm.set("$"+str(value * .10))     vacation.set("$"+str(value * .04))     cardown.set("$"+str(value * .04))     homedown.set("$"+str(value * .02))     guiltfree.set("$"+str(value * .20))     projection.set("$"+str(value * .10 * 1 + 0.05/4 ** 4*10))  except valueerror:     pass 

for reason, output when pass in 100 $100.001953125

what doing wrong in projection.set section of code math?

i'm not 100% sure trying do, want implement formula

a = p(1+r/m)^mt 

you need

projection.set("$"+str(value * .10 *( 1 + 0.05/4) ** (4*10))) 

rather than

projection.set("$"+str(value * .10 * 1 + 0.05/4 ** 4*10)) 

(remember pemdas)


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -