NumPy linspace

  • Post category:NumPy

In this NumPy tutorial, you’ll learn how to use the NumPy linspace function in Python. In the following example, this function will create a NumPy array of six numbers between 0 and 10 that have an equal gap.

# import numpy module
import numpy as np

# create a numpy array
var = np.linspace(0, 10, 6)

# print the array
print(var)

Output:

[ 0.  2.  4.  6.  8. 10.]

Free resources to learn advanced skills: AiHints and CodeAllow