How to Generate a Random Float From 0 to 1


In this example we will show how to generate a random float from 0 to 1 in Python NumPy.

Source Code

from numpy import random

# generate a random float from 0 to 1
n = random.rand()

print(n)

Output:

0.45116062199425666
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments