Python math.sqrt() Method
Example
Find the square root of different numbers:
# Import math Library
import math
# Return the square root of
different numbers
print (math.sqrt(9))
print (math.sqrt(25))
print
(math.sqrt(16))
Try it Yourself »
Definition and Usage
The math.sqrt()
method returns the square root of a number.
Note: The number must be greater than or equal to 0.
Syntax
math.sqrt(x)
Parameter Values
Parameter | Description |
---|---|
x | Required. A number to find the square root of. If the number is less than 0, it returns a ValueError. If the value is not a number, it returns a TypeError |
Technical Details
Return Value: | A float value, representing the square
root of a number |
---|---|
Python Version: | 1.4 |