anonymous
  • anonymous
care to comment on this code for problem 4?
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
def findMaxExpenses(salary,save,preRetireGrowthRates,postRetireGrowthRates,epsilon): preretirement=nestEggVariable(salary,save,preRetireGrowthRates) index=len(preRetireGrowthRates)-1 startmoney=preretirement[index] low=0 high=startmoney counter=1 guess=startmoney/2.0 while guess-epsilon: break def nestEggVariable(salary, save, growthRates): cashpile=[] money=0 counter=0 for counter in range (0,len(growthRates)): money=money+(0.01 * growthRates[counter]) * money+(salary *(.01 *save)) cashpile.append(money) return cashpile def postRetirement(savings, growthRates, expenses): cashpile=[] money=savings counter=0 for counter in range (0,len(growthRates)): money=money+(0.01 * growthRates[counter]) * money-expenses cashpile.append(money) return cashpile def testFindMaxExpenses(): salary = 10000 save = 10 preRetireGrowthRates = [3, 4, 5, 0, 3] postRetireGrowthRates = [10, 5, 0, 5, 1] epsilon = .01 expenses = findMaxExpenses(salary, save, preRetireGrowthRates, postRetireGrowthRates, epsilon) print expenses # Output should have a value close to: # 1229.95548986
anonymous
  • anonymous
pls use pastebin or dpaste.com to post code. does it work?? were you looking for style or implementation comments?
anonymous
  • anonymous
It finds the answer in 20 iterations. I had a bit of a problem deciding how to make the program stop running. I made a condition that stopped the counter if the ending balance was between epsilon and -epsilon. My question is if epsilon wasn't .01 this wouldn't work as well, is there a better way to make an end condition?

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
Don;t think so.. You have to decide how precise you want your answer to be - the more precise, the more iterations. I imagine since the problem concerns money, you could round everything to cents, multiply by one-hundred and work in integers but that is sorta the same thing.
carlsmith
  • carlsmith
You really will need to use a code host, github, dpaste, something like that, to put up that much code. Then people can easily grab a copy, put in some print statements and play around with your script a bit.

Looking for something else?

Not the answer you are looking for? Search for more explanations.