numpy.arange() in Python

This numpy.arange() function is used to generates an array with evenly spaced values with the given interval. Commonly this function is used to generate an array with default interval 1 or custom interval.

Basic Syntax

numpy.arange() in Python function overview
numpy.arange() in Python function overview

Following is the basic syntax for numpy.arange() function:

arange(start, stop, step, dtype)
Returns Array with evenly spaces values with the given interval.

The Parameters used are:

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.

Returns

The arange() function returns the array of evenly spaced values.

Example

Following is the example for Numpy arange() function in Python:

The output should be:

Array =
[0, 1, 2, 3, 4, 5, 6, 7, 8]
Array =
[ 6, 7, 8, 9, 10, 11, 12, 13, 14]
Array =
[ 5, 10, 15, 20, 25, 30, 35, 40, 45]
Array =
[[0, 1, 2],
[3, 4, 5],
[6, 7, 8]]

LEAVE A REPLY

Please enter your comment!
Please enter your name here