Python math function - sqrt
# Introduction to Python math.sqrt()
Python math.sqrt() is an inbuilt function that is used to calculate the square root of a given number. It returns the square root of the given number and if the number is negative then it raises a ValueError exception. The syntax of sqrt() function is:
math.sqrt(x)
Where x is the number whose square root is to be calculated.
The math.sqrt() function is a part of the math module which is a built in module in Python. It is used to perform mathematical operations on numbers. This module provides access to the mathematical functions defined by the C standard.
The math.sqrt() function is used to calculate the square root of a given number. It is a part of the standard math module, so we do not need to install it separately. To access the math module, we need to import it in our program.
This function is used to calculate the square root of a number and return a floating point number. The argument passed to the sqrt() function must be a positive real number, otherwise it will raise a ValueError exception. If a negative number is passed to this function, it will raise a ValueError exception.
The math.sqrt() function is useful in mathematical calculations such as finding the hypotenuse of a right triangle, calculating the area of a circle, etc. It is also useful for finding the square root of a number without using loops.
The math.sqrt() function can be used in both Python 2.x and Python 3.x.
Worried About Failing Tech Interviews?
Attend our webinar on
"How to nail your next tech interview" and learn
.png)
Hosted By
Ryan Valles
Founder, Interview Kickstart

Our tried & tested strategy for cracking interviews

How FAANG hiring process works

The 4 areas you must prepare for

How you can accelerate your learnings
Register for Webinar
The **sqrt** function is a Python math function used to calculate the square root of a number. The syntax for the **sqrt** function is:
```
math.sqrt(x)
```
Where **x** is the number for which you want to calculate the square root.
For example, to calculate the square root of 25, you would use the following code:
```
import math
result = math.sqrt(25)
print(result)
```
This code would print out the result 5.0.