numpy.arrange()

It creates an array by using the evenly spaced values over the given interval. The interval mentioned is half opened i.e. [Start, Stop]).

Syntax

snippet
numpy.arrange(start, stop, step, dtype)

Parameters

It accepts the following parameters.

  1. start: The starting of an interval. The default is 0.
  2. stop: represents the value at which the interval ends excluding this value.
  3. step: The number by which the interval values change.
  4. dtype: the data type of the numpy array items.

Return

An array within the specified range is returned.

Example 1

snippet
import numpy as np
arr = np.arange(0,10,2,float)
print(arr)

Output:

Output
[0. 2. 4. 6. 8.]

Example 2

snippet
import numpy as np
arr = np.arange(10,100,5,int)
print("The array over the given range is ",arr

Output:

Output
The array over the given range is [10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95]
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +