Python3 sqrt() Function
Description
sqrt() The method returns the square root of a number x.
Syntax
The syntax of the sqrt() method is as follows:
import math
math.sqrt( x )
**Note:** sqrt() cannot be accessed directly; you need to import the math module and call the method through the static object.
Parameters
- x -- a numeric expression.
Return Value
Returns the square root of a number x.
Example
The following shows examples of using the sqrt() method:
Example
#!/usr/bin/python3
import
math
Import the math module
(
"
math.sqrt(100) :
"
,
math
.
sqrt
(
100
)
)
(
"
math.sqrt(7) :
"
,
math
.
sqrt
(
7
)
)
(
"
math.sqrt(math.pi) :
"
,
math
.
sqrt
(
math
.
pi
)
)
Running the example above produces:
math.sqrt(100) : 10.0
math.sqrt(7) : 2.6457513110645907
math.sqrt(math.pi) : 1.7724538509055159
Python3 Numbers