Python Numpy.arange()

In this tutorial, you will learn about python numpy arange() function. It creates a ndarray with evenly spaced items or elements.


The syntax of python numpy arange() function is



numpy arange() function can takes four parameters

  • start(optional): starting value from where the array will start, by default it is zero
  • stop: It represent the number , to stop the array upto this number.
  • step(Optional): it will define the gap between two integers. By default, the gap between two integers will be 1.
  • dtype: It is type of the items of output array, by default , it’s none.


Check The examples below to understand


Example #1

creating an array of 6 items using arange() numpy function.



Example #2

It will return a numpy array from -4 to 9



Example #3

cearting a numpy array of even numbers from 2 to 20, using arange() function



Start with Numpy


Python numpy.empty()