Skip to main content

np.arange()

np.arange(start, stop, step)

Returns an array of numbers beginning with start, incrementing by step, and ending before stop. If start or step is omitted, the default values will be 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:
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])