Home>Article>Backend Development> What function is sqrt?
What is the function sqrt?
sqrt() is a function used to calculate the square root of a number x.
Syntax
The following is the syntax of the sqrt() method:
import math math.sqrt( x )
Note: sqrt() cannot be accessed directly. You need to import the math module and call it through a static object. method.
Parameters
x -- Numeric expression.
Return value
Returns the square root of the number x.
Example
The following shows an example of using the sqrt() method:
#!/usr/bin/python import math # This will import math module print "math.sqrt(100) : ", math.sqrt(100) print "math.sqrt(7) : ", math.sqrt(7) print "math.sqrt(math.pi) : ", math.sqrt(math.pi)
The output result after running the above example is:
math.sqrt(100) : 10.0 math.sqrt(7) : 2.64575131106 math.sqrt(math.pi) : 1.77245385091
The above is the detailed content of What function is sqrt?. For more information, please follow other related articles on the PHP Chinese website!