python range for float 1

python range for float

>>> import numpy as np
>>> np.arange(0.0, 1.0, 0.1)
array([ 0. ,  0.1,  0.2,  0.3,  0.4,  0.5,  0.6,  0.7,  0.8,  0.9])

Here is what the above code is Doing:
1. We’re importing the numpy library.
2. We’re creating an array of numbers from 0.0 to 1.0, in steps of 0.1.
3. We’re printing the array.

You can also create arrays of random numbers using the numpy.random module.

>>> import numpy as np
>>> np.random.random((3,3))
array([[ 0.84955693, 0.92909849, 0.84955693],
[ 0.92909849, 0.84955693, 0.92909849],
[ 0.84955693, 0.92909849, 0.84955693]])

Similar Posts