Creating Array using arange()

Vandana Srivastava
2 min readJul 13, 2024

The arange() function is part of the NumPy library in Python and is used to create arrays with regularly incrementing values.

Syntax:

arange([start,] stop[, step,], dtype=None, *, like=None)

Here’s a breakdown of its parameters:

  • start (optional): The starting value of the sequence. The default is 0.
  • stop (required): The end value of the sequence.
  • step (optional): The spacing between values. The default is 1.
  • dtype (optional): The data type of the output array. If not given, it is inferred from the other input arguments.

Use Cases:

  • Generating sequences of numbers for iteration in loops.
  • Creating time intervals.
  • Producing sample points for functions.

Creating 1-D array using arange()

Note: Can’t create a 2-D array in arange(). But we can convert arange() into a 2-D or 3-D Array using reshape.

That’s it for now, let’s deep dive into NumPy in my upcoming blogs.

And can learn more from my Github profile:

Also Matplotlib learnings from github:

Pandas Learnings from github:

Check some of my other blogs in this series:

--

--