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
Use math.sqrt()
to return the square root of integer 5
:
import mathprint(math.sqrt(5))
The above code gives the following output:
2.23606797749979
Use math.sqrt()
to return the square root of the float 5.5
:
import mathprint(math.sqrt(5.5))
The above code gives the following output:
2.345207879911715
Codebyte Example
Run the following example that uses the math.sqrt()
function to understand its working:
All contributors
- ishg-15321 total contributions
- Anonymous contributorAnonymous contributor2 total contributions
- christian.dinh2476 total contributions
- Anonymous contributorAnonymous contributor3071 total contributions
- Anonymous contributorAnonymous contributor186 total contributions
- ishg-153
- Anonymous contributor
- christian.dinh
- Anonymous contributor
- Anonymous contributor
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.