How can i create a random array of floats from 0 to 5 in python

Boris FELD lothiraldan at
Tue Mar 12 18:25:36 CET 2013

You can use [random.random() * 5 for x in range(100)] but works only
on range [0, 5). If you want to include 5, you will need more code.

FELD Boris

2013/3/12 Norah Jones <nh.jones01 at>:
> I want to create a random float array of size 100, with the values in the
> array ranging from 0 to 5. I have tried random.sample(range(5),100) but that
> does not work. How can i get what i want to achieve?
> --

More information about the Python-list mailing list