why sqrt is not a built-in function?

Alan Gauld alan.gauld at yahoo.co.uk
Thu Jan 14 12:54:55 EST 2021


On 14/01/2021 17:44, Denys Contant wrote:
> I don't understand why sqrt is not a built-in function. 
> Why do we have to first import the function from the math module?
> I use it ALL THE TIME!

because pow() is a builtin function and

root = pow(x,0.5)

is the same as

root = math.sqrt(x)

As is

root = x ** 0.5

which is also builtin.

My question is: why do we even have a sqrt() in the
math module given that pow() and ** are already there?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Python-list mailing list