math.sqrt in Python

Returns the square root of the specified number.

math.sqrt (x)

-> float

x - The number from which you want to extract the root. 


  from math import sqrt 


sqrt (1) # 1.0
sqrt (2) # 1.4142135623730951
sqrt (9) # 3.0

sqrt (0) # ValueError: math domain error
sqrt (-9) # ValueError: math domain error

Notes

sqrt short for square root (square root).





Get Solution for free from DataCamp guru