Skip to main content

np.arange()

np.arange(start, stop, step)

An array of numbers starting with start, increasing/decreasing in increments of step, and stopping before (excluding) stop. If start or step are omitted, the default values are 0 and 1, respectively.

Input:
start : integer (default 0)
The starting value of the sequence.
stop : integer
The end value of the sequence, which is not included in the output.
step : integer (default 1)
The difference between each two consecutive values.
Returns:
array - an array of numbers from start to stop, incremented by step
Return Type:
array

np.arange(1, 9, 2)

array([1, 3, 5, 7])

np.arange(10, 2, -3)

array([10, 7, 4])