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

Hey I'm on pset4 problem 4 and I don't know how to implement the guessing procedure into the script please help. Here is what I have so far http://dpaste.com/hold/528870/ .

OpenStudy (anonymous):

I used the bisection method of successive approximation that was taught in one of the lectures. According to this method, you set a high and low value for the expenses and guess half way in between. The code will look something like this: high = savings low = 0 expenses = (high + low) / 2 If your guess is too high, then you know the right answer must be somewhere between your guess and 0, so expenses becomes the new upper bound: high = expenses Likewise, if a guess is too low, expenses becomes the lower bound for the next guess, and you repeat this process until you get a result whose absolute value is less than epsilon, which means you will probably have to use a while-loop involving epsilon: while abs(final_result) > epsilon: expenses = (high + low) / 2 etc....

OpenStudy (anonymous):

O thanks for actually replying and sorry for not going back and saying this earlier but i reposted my question and people helped me. Thanks anyway though.

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!