# Numpy arange()

Numpy

``numpy.arange(start,stop, step,dtype=None)``
Return ndarray by using start, stop, step and dtype.
 `start` number, Optional,default is 0, Start value of the elements `stop` number, Optional,Upper limit of start ( value not included ). `step` number, Optional, default is 1 `dtype` type of output, Optional, default is dtype of input arguments

## Examples

Creating array ( start = 0 )
``````import numpy as np
print(np.arange(0)) # []``````
``print(np.arange(5)) # [0 1 2 3 4]``
With start stop and step options
``print(np.arange(start=1,stop=5,step=2)) # [1 3]``
``print(np.arange(1,5))``
Output
``[1 2 3 4]``
Creating empty array
``````x=np.arange(3,3)
print(x) # []``````

## Using start stop and step

Sample codes below are with output.
``print(np.arange(start=1,stop=5,step=2)) # [1 3]``
``print(np.arange(1,5,2)) # [1 3]``

## Using negative start, strop and steps

``print(np.arange(-10,-3,2)) # [-10  -8  -6  -4]``
``print(np.arange(-3,-10,-2)) # [-3 -5 -7 -9]``
``print(np.arange(-3,10,3)) # [-3  0  3  6  9]``
``print(np.arange(.4, 2.8,.7)) # [0.4 1.1 1.8 2.5]``
``print(np.arange(-2.8, 2,.9)) # [-2.8 -1.9 -1.  -0.1  0.8  1.7]``

## dtype

We can use option dtype ( dtype=np.int32 )
``print(np.arange(1,5,dtype=np.int8)) # [1 2 3 4]``
``print(np.arange(1,5,dtype=np.float64)) # [1. 2. 3. 4.]``
Getting the dtype
``````my_ar=np.arange(1,5,dtype=np.float64)
print(my_ar.dtype) # float64``````

Subscribe to our YouTube Channel here

## Subscribe

* indicates required
Subscribe to plus2net

plus2net.com