Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 15 Online
OpenStudy (anonymous):

Now I'm working on problem set 4, the retirement fund. My functions for the first 3 questions seem to be working, although the accuracy diminishes with each one. Can anyone tell me why? Or are they close enough? (The output printed on codepad shows what my functions return compared to what the results should have been.) http://codepad.org/97UtRlNM

OpenStudy (anonymous):

Whoops! Try this link instead: http://codepad.org/6siOFOL6

OpenStudy (anonymous):

nestEggFixed: you have an extra year in the answer - easiest way to fix it might be to change the limit in line 24 to 'years - 1', year one was index zero, year two is index one ... year 'year' is index year - 1 nestEggVariable: the problem instruction says that growthRate[0] is irrelevant, it shouldn't be used. try growthRates[x] instead of growthRates[x-1] in line 63 postRetirement: in line 97 you use growthRates[0], the first time you get to line 101 you use it again - so maybe growthRates[x] instead of growthRates[x-1] in line 101 in a calculation, if just one of the operands is type float then the result will be type float. you can mix Numeric types in a calculation - you don't have to turn all of the operands into a float -you can but you don't have to. if you want a float as a result and it isn't obvious that one of the operands will be a float (because they are variables) then using float(variable) for one of them will ensure a float type result. hope that made sense

OpenStudy (anonymous):

Thanks- that fixed the problems. Before I posted this code, I thought that the problem was that I wasn't using floats, so I went through and changed all the numbers to floats. But that had absolutely no affect whatsoever on the result. I just didn't go back and delete all the changes to floats.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!