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

I am working on 1.4 part II homework, and am a little confused about how to handle the square and quadratic roots. I know there is a math.sqrt() function but is there an operator for the square root? And what can i do for the quadratic root besides take two square roots?

OpenStudy (anonymous):

Oh i also realized i can take something to the 1/2 or .25 power, but am still curious if there is an explicit way of taking roots.

OpenStudy (anonymous):

http://www.tutorialspoint.com/python/python_basic_operators.htm has a pretty nice list of built in python operators. There is no operator syntax for taking like what I think you are asking about, but exponentiation works just fine e.g. x**(0.5). I'm not sure how its implemented but if I had to guess math.sqrt() probably implements some sort of fast square root algorithm and might be faster than x**(0.5), but thats just my guess.

OpenStudy (anonymous):

AFAIK (and that’s not much here), unless you import NumPy module, you’re stuck with `x**(0.5)`

OpenStudy (anonymous):

alright, i just wanted to make sure i wasn't missing anything.

OpenStudy (anonymous):

pow(x, y) x ** y

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!