- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Return evenly spaced values within a given interval and step size in Numpy

Create an array with int elements using the **numpy.arange()** method. The 1st parameter is the "**start**" i.e. the start of the interval. The 2nd parameter is the "**end**" i.e. the end of the interval. The
3rd parameter is the step size i.e. the spacing between values. The default step size is 2 here.

Values are generated within the half-open interval [start, stop). For integer arguments the function is equivalent to the Python built-in range function, but returns an ndarray rather than a list.

The stop is the end of interval. The interval does not include this value, except in some cases where step is not an integer and floating point round-off affects the length of out. The step is the spacing between values. For any output out, this is the distance between two adjacent values, out[i+1] - out[i]. The default step size is 1. If step is specified as a position argument, start must also be given.

## Steps

At first, import the required library −

import numpy as np

Creating an array with int elements using the numpy.arange() method. We have set the step size to 2 here −

arr = np.arange(15, 30, step = 2) print("Array...\n", arr)

Get the type of the array −

print("\nArray type...\n", arr.dtype)

Get the dimensions of the Array: −

print("\nArray Dimensions...\n",arr.ndim)

Get the shape of the array −

print("\nOur Array Shape...\n",arr.shape)

Get the number of elements of the Array −

print("\nNumber of elements in the Array...\n",arr.size)

## Example

import numpy as np # Creating an array with int elements using the numpy.arange() method # The 1st parameter is the "start" i.e. the start of the interval # The 2nd parameter is the "end" i.e. the end of the interval # The 3rd parameter is step size i.e. the spacing between values. The default step size is 1 # We have set the step size to 2 here arr = np.arange(15, 30, step = 2) print("Array...\n", arr) # Get the array type print("\nArray type...\n", arr.dtype) # Get the dimensions of the Array print("\nArray Dimensions...\n",arr.ndim) # Get the shape of the Array print("\nOur Array Shape...\n",arr.shape) # Get the number of elements of the Array print("\nNumber of elements in the Array...\n",arr.size)

## Output

Array... [15 17 19 21 23 25 27 29] Array type... int64 Array Dimensions... 1 Our Array Shape... (8,) Number of elements in the Array... 8

- Related Questions & Answers
- Return evenly spaced values within a given interval in Numpy
- Return evenly spaced numbers over a specified interval in Numpy
- Return evenly spaced numbers over a specified interval and do not set the endpoint in Numpy
- Return evenly spaced numbers over a log scale in Numpy
- Return numbers spaced evenly on a geometric progression in Numpy
- Return evenly spaced numbers over a specified interval and set the number of samples to generate in Numpy
- Return evenly spaced numbers on a log scale and set the base in Numpy
- Return evenly spaced numbers on a log scale and do not set the endpoint in Numpy
- Return evenly spaced numbers on a geometric progression and do not set the endpoint in Numpy
- Return numbers spaced evenly on a geometric progression but with negative inputs in Numpy
- Return numbers spaced evenly on a geometric progression but with complex inputs in Numpy
- Return evenly spaced numbers on a log scale and set the number of samples to generate in Numpy
- Return evenly spaced numbers on a geometric progression and set the number of samples to generate in Numpy
- How to make xticks evenly spaced despite their values? (Matplotlib)
- Mask an array inside a given interval in Numpy