Bring Your Logic using Python
341 subscribers
109 photos
1 video
4 files
544 links
Logic building using Python : Materials, links, e-books and Code snippets
Download Telegram
Do you need something like range() but with float numbers? Try numpy.arange()

>>> range(0, 5, 0.5) #Error!

>>> np.arange(0, 5, 0.5)
array([0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. , 4.5])


If you need exactly X steps, but one step is not a short decimal number, you can use:

>>> np.linspace(0, 1, 4)
array([0., 0.3333333, 0.6666667, 1.])