why sqrt is not a built-in function?
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Jan 15 00:13:36 EST 2021
Aother thing to consider is that math.sqrt is not the only
sqrt function in Python. There is also one in cmath, and
in the wider ecosystem, another one in numpy. Being explicit
about which one you're using is a good thing.
Concerning exponentiation, it can be used to achieve the same
thing as sqrt, but the sqrt function probably uses a more
efficient algorithm.
Also, exponentiation assumes you're okay with getting a
complex result:
>>> (-27)**0.5
(3.181725716174721e-16+5.196152422706632j)
So it's not quite the same thing as math.sqrt().
--
Greg
More information about the Python-list
mailing list