Let’s see how to calculate square root in Numpy Python module.

## Numpy sqrt

Import Numpy, use sqrt numpy function and calculate square root for your array just like in the numpy code below.

import numpy as np my_array = np.array([2, 3, 4, 9, 16]) square_root = np.sqrt(my_array) print("Square root equals: " + str(square_root))

Square root has been calculated and printed out.

## How to calculate the square root of a single number in NumPy

In addition to calculating the square root of an array, you can also calculate the square root of a single number using the sqrt function. For example, the following code will calculate the square root of the number 16:

import numpy as np number = 16 square_root = np.sqrt(number) print("The square root of 16 is: " + str(square_root))

This code will print the following output:

The square root of 16 is: 4