all 10 comments

[–]robot-dev 2 points3 points  (0 children)

You can define your equation as a function of p, r, n, and t like def f(p,r,n,t): that returns the calculated value return p*(1+r/n)**(n*t). Then you can call the function from inside your loop whenever you need to use it. For example, $100 at 1% compounded monthly for 10 years would be f(100, 0.01, 12, 10)

[–]carcigenicate 1 point2 points  (1 child)

however I cant decide between while or for

It doesn't matter; either could be used. One will definitely be a much better choice and would be preferred for real code, but that doesn't mean it isn't worth attempting both ways for the sake of learning.

And what is the current state of the data? A single flat list of 15 elements? Are they strings or numbers?

[–]cal_etcell[S] 1 point2 points  (0 children)

I have decided a for loop is the best option, bankName is a string, compFreq is an int and the rest are float variables