The following small series for everyone to bring a python random function small composition think very good, now share to everyone, also for everyone to do a reference. Follow the small series together to see it.
Describe
The random () method returns a randomly generated real number that is within the range of [0,1].
Grammar
The following is the syntax for the random () method:
Import Randomrandom.random ()
Note: The random () is not directly accessible, 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 that is within the range of [0,1].
Instance
The following shows an example of using the random () method:
#!/usr/bin/pythonimport random# generates the first random number print "random ():", Random.random () # Generates a second random number print "random ():", Random.random ( )
When the above instance is run, the output is:
Random (): 0.281954791393random (): 0.309090465205
"Recommended"
1. A detailed description of the mathematical and random numbers in the Python standard library (math package, random package)
2. Share a tutorial on how to generate random numbers in Python module
3. Share an example tutorial on random (randomly generated numbers) in Python
4. Share Python Random example of a method that generates n random numbers that are not duplicated in a range
5. Python Random Module (get random number) common methods and use examples
6. Python Random Module Common methods
7. Python Module Learning: Random number generation