The arange()
function in Python returns evenly spaced values within a given interval from NumPy.
arange([start, ]stop, [step, ]dtype=None, *, like=None)
The arange()
function takes the following parameter values:
start
: this represents the start of the interval. The default value for start
is 0
. This is optional.stop
: this represents the end of the interval. The interval does not include this value.step
: this represents the spaces between the values. This is optional.dtype
: this represents the data type of the output array.like
: this represents the array-like object or prototype.The arange()
function returns an array of evenly spaced values.
from numpy import arange# creating the arraymy_array = arange(1, 11, 1, dtype = int)print(my_array)
arange
function from numpy
library.arange()
function, we create an array to start at 1
, stop at 11
(11
not included), with a step size of 1
, and with an int
data type. The result is assigned to the variable my_array
.my_array
.