How to Create a NumPy Array Using the arange() Function

arange(start, stop, step, dtype)
ParameterDescription
start[Optional] provide the start of the interval range.
stopprovide end of the interval range.
step[Optional] the spacing between two adjacent values.
dtype[Optional] dtype is the type of output array.

np arange(): How to Use numpy arange() Function

Example 1:

import numpy np
np.arange(1, 11)

//Reults:
array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])

Example 2:

import numpy np
np.arange(1, 14, 4)

//Output
array([ 1, 5, 9, 13])

Example 3: NumPy.arange() method Example
 

>>> import numpy as np
>>> np.arange(5)
array([0, 1, 2, 3, 4])
>>> np.arange(5.0)
array([ 0., 1., 2., 3., 4.])

I hope you get an idea about numpy aranges include endpoint.


#py  #python 

How to Create a NumPy Array Using the arange() Function
1.00 GEEK