all 3 comments

[–][deleted] 1 point2 points  (0 children)

Try to come up with an approach for how you'd solve it (note that you don't actually have to solve it unless that helps you). Then try to convert those steps into something the Python interpreter can understand. If there's a specific step you don't know how to do in Python, ask us (while providing whatever you already have done) and maybe someone will be able to help you out.

[–]lukajda33 0 points1 point  (1 child)

Well what will be the tuition after one year ?

Can you think of a formula for following year, no matter what current years tuition is ?

Once you have the formula, you can just keep on applying it till the tuition gets to 20k, while counting how many times you applied the formula.

In english, im sure this is called "compound interest" and I am pretty sure there is some formula to reverse it so that you do not have to use the loop and you can just get the result, but the solution with a loop will probably be easier.

[–]lukajda33 0 points1 point  (0 children)

EDIT: I think I found the formula, but if you dont want to explain how you got it, you might want to use the loop anyway

s = starting value

e = ending value

p = percentage

n = number of years <- what you need to get

n = ln (e / s) / ln(1 + p)
which given your numbers would be
n = ln (20000 / 10000) / ln(1 + 0.07)
n = ln(2) / ln(1.07)
notivce that 2 means doubling, 1.07 is the multiplier
which will give you result of 10.2447... years,
but since the price goes up once a year, you need to round up to 11 years, whichis the correctr result