0

I would like to generate n float numbers between two numbers. I am giving an example of what i am expecting.

num_list = [1.2, 2.9]

I am expecting a output something like this below but not necessarly same. I want to generate 100 numbers between two numbers. :

big_list = [1.2,1.201,...,............,2.885,2.9]
Mainland
  • 4,110
  • 3
  • 25
  • 56
  • Sorry but I don't understand why you asked this. Googleing your **exact same question** results in [this page](https://stackoverflow.com/questions/6683690/making-a-list-of-evenly-spaced-numbers-in-a-certain-range-in-python). Why? – Asocia Jun 05 '20 at 16:26
  • I tried but I could not get right answer due to my wording. – Mainland Jun 06 '20 at 18:28

1 Answers1

2

You can use the method linspace():

import numpy as np

l = np.linspace(1.2,2.9,100)

print(len(l))

print(l)

Output:

100
[1.2        1.21717172 1.23434343 1.25151515 1.26868687 1.28585859
 1.3030303  1.32020202 1.33737374 1.35454545 1.37171717 1.38888889
 1.40606061 1.42323232 1.44040404 1.45757576 1.47474747 1.49191919
 1.50909091 1.52626263 1.54343434 1.56060606 1.57777778 1.59494949
 1.61212121 1.62929293 1.64646465 1.66363636 1.68080808 1.6979798
 1.71515152 1.73232323 1.74949495 1.76666667 1.78383838 1.8010101
 1.81818182 1.83535354 1.85252525 1.86969697 1.88686869 1.9040404
 1.92121212 1.93838384 1.95555556 1.97272727 1.98989899 2.00707071
 2.02424242 2.04141414 2.05858586 2.07575758 2.09292929 2.11010101
 2.12727273 2.14444444 2.16161616 2.17878788 2.1959596  2.21313131
 2.23030303 2.24747475 2.26464646 2.28181818 2.2989899  2.31616162
 2.33333333 2.35050505 2.36767677 2.38484848 2.4020202  2.41919192
 2.43636364 2.45353535 2.47070707 2.48787879 2.50505051 2.52222222
 2.53939394 2.55656566 2.57373737 2.59090909 2.60808081 2.62525253
 2.64242424 2.65959596 2.67676768 2.69393939 2.71111111 2.72828283
 2.74545455 2.76262626 2.77979798 2.7969697  2.81414141 2.83131313
 2.84848485 2.86565657 2.88282828 2.9       ]
Red
  • 26,798
  • 7
  • 36
  • 58