Python provides different functions and operators in order to calculate the square root of the given number. This number can be positive, negative, zero, real or complex number. There is also the Numpy library which providessqrt()
function in order to calculate square root.
Python提供了不同的函数和运算符,以便计算给定数字的平方根。 该数字可以是正数,负数,零,实数或复数。 还有一个Numpy库,它提供sqrt()
函数以计算平方根。
数学模块sqrt()函数 (Math Module sqrt() Function)
The most known and popular function is the sqrt()
function which is provided by the math
module or library. We can just provide the number we want to calculate square root for this function. In the following example, we will import the math
module and then use the sqrt() function.
最著名和最受欢迎的函数是math
模块或库提供的sqrt()
函数。 我们只需要提供要计算该函数平方根的数字即可。 在下面的示例中,我们将导入math
模块,然后使用sqrt()函数。
import math
math.sqrt(25)
//Result will be 5.0
math.sqrt(9)
//Result will be 3.0
math.sqrt(90)
//Result will be 9.486832980505138
math.sqrt(900)
//Result will be 30.0
math.sqrt(90000)
//Result will be 300.0
math.sqrt(49)
//Result will be 7.0

零平方根(Square Root of Zero)
Zero is a special number where it can produce different results according to the different operations. When we take the square root of the zero we will get zero as a result.
零是一个