VOOZH about

URL: https://www.geeksforgeeks.org/python/how-to-create-a-sequence-of-linearly-increasing-values-with-numpy-arange/

⇱ How to Create a Sequence of Linearly Increasing Values with Numpy Arrange? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Create a Sequence of Linearly Increasing Values with Numpy Arrange?

Last Updated : 23 Jul, 2025

In this article, we are going to create a sequence of linearly increasing values with Numpy arrange() function. 

Getting Started

By using arrange() function, we can create a sequence of linearly increasing values. This method returns an array with evenly spaced elements as per the interval. The interval mentioned is half opened i.e. [Start, Stop)

Syntax: 

numpy.arrange(start, stop, step)

Parameters:

  • start is the starting value
  • stop is the ending value
  • step is a linear increment value with in the given range. It is optional. By default, it is 1.

Return Type:

  • Return an array of elements

For example:

numpy.arrange(1,10,3) # array([1,4,7])

Here, we have given a range from 1 to 10(start = 1 and stop = 10) but we specified step=3. That means it skips every 3 elements in a range. So In this way, we can increase linearity in data.

Example 1: 

Create elements within range with 3-step linearly.

Output:

👁 Image

Example 2:

Create elements within range with 5-step linearly.

 Output:

👁 Image

Example 3:

Create elements within the range of 34 to 50 with 5-step linearly. 

Output:

[34 39 44 49]
Comment