How it works ?
Returns an array with evenly spaced elements as per the interval.
The interval mentioned is half opened i.e. [Start, Stop).
Length of array being generated = Ceil((Stop - Start) / Step)
Parameters : arange(start, stop, step, dtype)
- start : [optional] start range of interval . By default start = 0
- stop : end range of interval.
- step : [optional] step size of interval. By default step size = 1
- dtype : type of output array[can be int, flaot, complex]
Code :
# Working of
# numpy.arange method
import numpy as geek
# reshape(2, 2) means 2D matrix of size 2 X 2
print("Array 1 : \n", geek.arange(4).reshape(2, 2), "\n")
print("Array 2 : ", geek.arange(4, 10), "\n")
print("Array 3 : ", geek.arange(4, 20, 3))
Output :
Array 1 : [[0 1] [2 3]] Array 2 : [4 5 6 7 8 9] Array 3 : [ 4 7 10 13 16 19]For an query contact me at : https://www.linkedin.com/in/mohit-gupta-003512116/



