# Return evenly spaced values within a given interval in Numpy

NumpyServer Side ProgrammingProgramming

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 spacing between values. The default step size is 1.

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

You need to create an array with int elements using the numpy.arange() method −

arr = np.arange(10, 20)
print("Array...\n", arr)

Display the array −

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


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)


## 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 the spacing between values. The default step size is 1
arr = np.arange(10, 20)
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...
[10 11 12 13 14 15 16 17 18 19]

Array type...
int64

Array Dimensions...
1

Our Array Shape...
(10,)

Number of elements in the Array...
10