anonymous
  • anonymous
In ps 4.4 (function testFindMaxExpenses) why is my answer 1229.95297872 and not 1229.95548986? Help greatly appreciated! http://dpaste.com/533442/
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
Hi, As far as I can tell the problem specifies that your answer should be *close* to 1229.95548986, so your numbers look ok. The reason *why* your answer is not the same stems from the fact that floating point representation of numbers (and that's what you get if you use decimal-dot notation in Python) cannot express any number with full precision. As a consequence small errors can accumulate over multiple operations and the final result can be different depending on the number of operations, their order, relative magnitude of numbers and so on. Numerical analysis deals with this kind of problems. That's why floating point numbers are not used for any serious calculations involving money.
anonymous
  • anonymous
Thanks for your response!
anonymous
  • anonymous
Hello, Changing the line in user mmapplebeck code: while test[-1] < 0 or test[-1] > epsilon: To this: while abs(test[-1]) > epsilon: Gave me exact answer as stated in ps4.py: 1229.95548986.

Looking for something else?

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