Python random random() Method
The Python random random() method returns a randomly generated real number in the half-open interval [0,1).
Python random random() Syntax
Here is the syntax of the random() method:
import random
random.random()
Note: random() is not directly accessible, you need to import the random module and then call the method via the random static object.
Python random random() Parameters
- None.
Python random random() Return Value
Returns a randomly generated real number in the semi-open interval [0,1).
Python random random() Example#1
The following shows an example of using the random() method.
#!/usr/bin/python3
import random
# First random number
print ("random() : ", random.random())
# Second random number
print ("random() : ", random.random())
Output: