In [1]:
import numpy as np

In [2]:
print(np.linspace(0, 10, 3))

[ 0.  5. 10.]

In [3]:
print(np.linspace(0, 10, 4))

[ 0.          3.33333333  6.66666667 10.        ]

In [4]:
print(np.linspace(0, 10, 5))

[ 0.   2.5  5.   7.5 10. ]

In [5]:
print(np.linspace(10, 0, 5))

[10.   7.5  5.   2.5  0. ]

In [6]:
print(np.linspace(0, 10, 3, dtype=int))

[ 0  5 10]

In [7]:
print(np.linspace(0, 10, 5))

[ 0.   2.5  5.   7.5 10. ]

In [8]:
print(np.linspace(0, 10, 5, endpoint=False))

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

In [9]:
result = np.linspace(0, 10, 5, retstep=True)

In [10]:
print(result)

(array([ 0. ,  2.5,  5. ,  7.5, 10. ]), 2.5)

In [11]:
print(type(result))

<class 'tuple'>

In [12]:
print(result[0])

[ 0.   2.5  5.   7.5 10. ]

In [13]:
print(result[1])

2.5

In [14]:
print(np.linspace(0, 10, 5, retstep=True)[1])

2.5

In [15]:
print(np.linspace(0, 10, 5, retstep=True, endpoint=False)[1])

2.0

In [16]:
print(np.linspace(0, 10, 5))

[ 0.   2.5  5.   7.5 10. ]

In [17]:
print(np.linspace(10, 0, 5))

[10.   7.5  5.   2.5  0. ]

In [18]:
print(np.linspace(0, 10, 5)[::-1])

[10.   7.5  5.   2.5  0. ]

In [19]:
print(np.flip(np.linspace(0, 10, 5)))

[10.   7.5  5.   2.5  0. ]

In [20]:
print(np.linspace(0, 10, 12).reshape(3, 4))

[[ 0.          0.90909091  1.81818182  2.72727273]
[ 3.63636364  4.54545455  5.45454545  6.36363636]
[ 7.27272727  8.18181818  9.09090909 10.        ]]

In [21]:
print(np.linspace(0, 10, 24).reshape(2, 3, 4))

[[[ 0.          0.43478261  0.86956522  1.30434783]
[ 1.73913043  2.17391304  2.60869565  3.04347826]
[ 3.47826087  3.91304348  4.34782609  4.7826087 ]]

[[ 5.2173913   5.65217391  6.08695652  6.52173913]
[ 6.95652174  7.39130435  7.82608696  8.26086957]
[ 8.69565217  9.13043478  9.56521739 10.        ]]]