random() method returns a randomly generated real number, which is in the range [0,1).
Grammar (Recommended learning: Python video tutorial)
The following is random() Method syntax:
1 2 3 |
|
Note: random() cannot be accessed directly. You need to import the random module and then call the method through the random static object.
Return value
Returns a randomly generated real number, which is in the range of [0,1).
Example
The following shows an example of using the random() method:
1 2 3 4 5 6 7 8 9 10 |
|
The output result after running the above example is:
1 2 |
|
For more Python-related technical articles, please visit the Python Tutorial column to learn!
The above is the detailed content of How to use python's random. For more information, please follow other related articles on the PHP Chinese website!