Python3 sqrt () function
description
sqrt () method returns the square root of the number x.
grammar
The following is the syntax sqrt () method:
import math math.sqrt( x )
Note: sqrt () is not directly accessible, you need to import math module, invoke the method through static object.
parameter
- x - numeric expression.
return value
Returns the square root of the number x.Examples
The following shows an example of using the sqrt () method:
#!/usr/bin/python3 import math # 导入 math 模块 print ("math.sqrt(100) : ", math.sqrt(100)) print ("math.sqrt(7) : ", math.sqrt(7)) print ("math.sqrt(math.pi) : ", math.sqrt(math.pi))
After running the above example output is:
math.sqrt(100) : 10.0 math.sqrt(7) : 2.6457513110645907 math.sqrt(math.pi) : 1.7724538509055159