random.random()
function. This method is used to generate a float random number less than 1 and greater or equal to 0.random()
is the most basic function of the random module.random()
return the next random floating-point number in the range [0.0, 1.0).random.random()
No parameters
a float random number less than 1 and greater or equal to 0.
Sample Programs :
1.
#importing random moduleimport randomprint("Printing random number using random.random() : ")print(random.random())
Output:
#importing random moduleimport randomfor i in range(5) :print("Printing random number", i+1, "using random.random() : ")print(random.random())
Output:
Comments