The sqrt method of the math module
The sqrt method of the math module returns the square root of the number specified in the parameter. A real value is always returned.
Syntax
import math
math.sqrt(number)
Example
Let's find the square root of the number 25:
import math
print(math.sqrt(25))
Result of code execution:
5.0
Example
Now let's get the square root of 10:
import math
print(math.sqrt(10))
Result of code execution:
3.1622776601683795
Example
Let's try to get the square root of a negative number:
import math
print(math.sqrt(-100))
As a result of executing the code, we will see an error:
ValueError: math domain error