Create arrays using the linspace() function
kodingwindow@kw:~$ python3
...
>>> from numpy import *
>>> linspace(0, 24, 3)
array([ 0., 12., 24.])

>>> linspace(0, 24, 4)
array([ 0.,  8., 16., 24.])

>>> linspace(0, 24, 5)
array([ 0.,  6., 12., 18., 24.])

>>> linspace(0, 24, 6)
array([ 0. ,  4.8,  9.6, 14.4, 19.2, 24. ])

>>> arr = linspace(0, 24, 5)
>>> arr
array([ 0.,  6., 12., 18., 24.])
>>> len(arr)
5

>>> min(arr)
0.0

>>> max(arr)
24.0

>>> sort(arr)
array([ 0.,  6., 12., 18., 24.])

>>> arr=append(arr, 30)
>>> arr
array([ 0.,  6., 12., 18., 24., 30.])

>>> arr=delete(arr, 0)
>>> arr=delete(arr, 1)
>>> arr
array([ 6., 18., 24., 30.])

>>> arr=insert(arr, 1, 12)
>>> arr
array([ 6., 12., 18., 24., 30.])

>>> arr.tolist()
[6.0, 12.0, 18.0, 24.0, 30.0]

>>> arr[::-1]
array([30., 24., 18., 12.,  6.])
Create arrays using the logspace() function
>>> from numpy import *
>>> arr = logspace(0, 20, 5)
>>> arr
array([1.e+00, 1.e+05, 1.e+10, 1.e+15, 1.e+20])

>>> len(arr)
5

>>> min(arr)
1.0

>>> max(arr)
1e+20
Advertisement