Arrays - arange()
NumPy - The Basics
1 min read
This section is 1 min read, full guide is 14 min read
Published Sep 22 2025, updated Aug 17 2026
11
Show sections list
0
Log in to enable the "Like" button
0
Guide comments
0
Log in to enable the "Save" button
Respond to this guide
Guide Sections
Guide Comments
NumPyPython
What np.arange() Does
numpy.arange()creates an array with evenly spaced values within a specified range.- It’s similar to Python’s built-in
range(), but returns a NumPy array instead of a list, and supports non-integer steps (like 0.5).
Function Signature
numpy.arange([start, ]stop, [step], dtype=None)- start → (optional) starting value (default = 0).
- stop → end value (excluded).
- step → spacing between values (default = 1).
- dtype → data type of the output array (optional).
Examples
import numpy as np# Default start=0, step=1np.arange(5) # → [0 1 2 3 4]# Custom start and stopnp.arange(2, 7) # → [2 3 4 5 6]# With stepnp.arange(1, 10, 2) # → [1 3 5 7 9]# With float stepnp.arange(0, 1, 0.2)# → [0. 0.2 0.4 0.6 0.8]np.arange() is a quick way to create number sequences as NumPy arrays, flexible with integer or float steps.