Ask your own question, for FREE!
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW) 21 Online
OpenStudy (anonymous):

my question it's in lecture 6 : why we use max(x,1) in fonction squarerootBi

OpenStudy (anonymous):

Is that when you are trying to get the square root of a number less than 1?

OpenStudy (anonymous):

Yes ,

OpenStudy (anonymous):

well, the square root of a number less than 1 will be greater than the square. eg What's the square root of 1/4, it's 1/2. So by taking the max value of 1 or the square you are ensuring that the answer is in the 'search range'. So for example, if you took 1/4 as your high, it would end up contentiously looping. I think that is demonstrated in the lecture.

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!