math.sqrt()

Returns the square root of numeric input x.

Syntax

math.sqrt(x)

If input x is a negative value, .sqrt() will return a ValueError: math domain error.

Example 1

Use math.sqrt() to return the square root of integer 5:

import math
print(math.sqrt(5))
# Output: 2.23606797749979

Example 2

Use math.sqrt() to return the square root of the float 5.5:

import math
print(math.sqrt(5.5))
# Output: 2.345207879911715
Edit this page on GitHub

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn Python on Codecademy

Edit this page on GitHub

Contributors