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:
- xx -- Required. A number. If x is not a number, returns TypeError. If the number is less than 0, returns ValueError.
Return Value
Returns a floating-point number representing the square root of a number.
Example
The following example returns the square root of a number:
Example
# Import the math package
import math
# Output the square root
print (math.sqrt(9))
print (math.sqrt(25))
print (math.sqrt(16))
import math
# Output the square root
print (math.sqrt(9))
print (math.sqrt(25))
print (math.sqrt(16))
Output result:
3.0 5.0 4.0Other extensions
Python math Module