anonymous
  • anonymous
the answers, for pset 4, that my functions are producing are close but not close enough for my comfort to the given results. Are any of you guys experiencing the same problem? Any advice?
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.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
Problem Set 4 ,Problem 3: I think there's an error in the given test case because it gives: [80000.000000000015, 54000.000000000015, 24000.000000000015, -4799.9999999999854, -34847.999999999985] The second last solution is way off from mine while the others are close. Maybe I'm wrong. Here's my answer for problem3: [81000.000000000015, 55860.000000000015, 26418.600000000013, -1996.2839999999851, -32036.209679999985] Is this close enough guys? Here's my code. Lemme know if I doing something wrong or how I can make my results more accurate: def postRetirement(savings, growthRates, expenses): """ - savings: the initial amount of money in your savings account. - growthRate: a list of the annual percent increases in your investment account (an integer between 0 and 100). - expenses: the amount of money you plan to spend each year during retirement. - return: a list of your retirement account value at the end of each year. """ # TODO: Your code here. #this is the list which will contain the retirement account values f = [] #the value of the retirement fund at the end of the first year EndOfYearOne = savings * (1 + 0.01 * (1 + growthRates[0])) - expenses #EndOfYearOne is now f[0] f.append(EndOfYearOne) #len(growthRates) tells me the number of years the person will be retired if len(growthRates) > 1 : for i in range (1, len(growthRates)): #so that can use the previous f[] value yearVariable = i - 1 #tut said I must calculate the increase of the remaining savings before subtracting expenses IncreaseInRemainingSavings = f[yearVariable] * ( 1 + (0.01 * (1 + growthRates[i]))) #calculating the value of the retirement fund at the end of the year EndOfYearValue = IncreaseInRemainingSavings - expenses f.append(EndOfYearValue) return f
anonymous
  • anonymous
interesting
anonymous
  • anonymous
There are reoccurring semantic bugs in calculation of savings. One here EndOfYearOne = savings * (1 + 0.01 * (1 + growthRates[0])) - expenses and the same one in for loop IncreaseInRemainingSavings = f[yearVariable] * ( 1 + (0.01 * (1 + growthRates[i]))) The idea is : newsavings = savings*1,X%, where X is growthRate of current year.

Looking for something else?

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

More answers

anonymous
  • anonymous
sorry no % sign in newsavings = savings*1,X% well commented code though :)

Looking for something else?

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