0
Why are my loop calculations doubling?
I need to calculate tuition rates that increase 2% every year, over the course of five years... I wrote my code: def main(startyear, endyear): Tuition=6000 For Year in range (startyear, endyear): If Year==1: Tuition=6000 Else: Tuition=(Tuition+(Tuition*.02)) print(.......) main(1, 6) Any idea as to why my calculations keep doubling an extra 2.4% after the first 2 years??
2 Respostas
+ 2
Because it's the way math works. You get 6120 after second loop iteration and then multiply the tuition (which is 6120) by 1.02, so you get 6242.4
+ 1
Duh! Thank you! Ultimate brain fart