np arange with Example — pythonpip.com

Difference between inbuilt range and np.arrange() Method

  • start: This is the number (integer or decimal) that defines the first value in the array.
  • stop: This is the number that defines the end of the array and isn’t included in the array.
  • step: This is the number that defines the spacing (difference) between each two consecutive values in the array and defaults to 1.
  • dtype: This is the type of the elements of the output array and defaults to None.

Simple Example Using np arrange

np.arange(0,6) np.arange(-3,2) np.arange(0,0)array([0, 1, 2, 3, 4, 5, 6]) array([-3, -2, -1, 0, 1, 2]) array([], dtype=int64)

np.arange() method using a single argument

np.arange(1) np.arange(5)array([0]) array([0, 1, 2, 3, 4])

np.arange() Method’s step Argument

array([0, 5])

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store