Python math.sqrt() Function
Python math.sqrt(x) The function returns the square root of x.
The number must be greater than or equal to 0.
Syntax
The syntax of the math.sqrt() function is as follows:
math.sqrt(x)
Parameter Description:
- x -- required, a number. If x is not a number, a TypeError is returned. If the number is less than 0, a ValueError is returned.
Return Value
Returns a floating-point number representing the square root of a number.
Example
The following example returns the square root of numbers:
Example
Import the math package
import
math
Output the square root
(
math
.
sqrt
(
9
)
)
(
math
.
sqrt
(
25
)
)
(
math
.
sqrt
(
16
)
)
Output result:
3.0
5.0
4.0
Python math Module