NumPy Tutorial NumPy Statistics NumPy References

NumPy - sqrt() function



The NumPy sqrt() function is used to calculate the square root of the given number.

Syntax

numpy.sqrt(x, out=None)

Parameters

x Required. Specify array (array_like) containing elements, of which the square root is calculated.
out Optional. Specify a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned.

Return Value

Returns the square root of each element of x.

Example:

In the example below, numpy sqrt() function is used to calculate the square root of each element present in array Arr.

import numpy as np

Arr = np.array([1, 4, 9, 16, 25])

print("The square root of values:")
print(np.sqrt(Arr))

The output of the above code will be:

The square root of values:
[ 1.  2.  3.  4.  5.]

❮ NumPy - Functions