This article mainly describes the relevant information about the random module of python, which has some reference value. interested friends can refer to the import random
Random. random () # generates a random floating point number between 0 and 1.
Random. randint (start, end) # Generate a random integer in the specified range.
For example, the minimum value of random. randint (1, 10) is 1 and the maximum value is less than or equal to 10.
Random. randrange (start, end) # Generate a random integer in the specified range.
Ramdom. randrange () has a minimum value of 1 and a maximum value of less than 10.
Random. choice randomly returns an element in the sequence.
Random. sample (sequence, which randomly retrieves several elements from the sequence at the same time) is used to specify multiple elements returned from the sequence at the same time.
The difference between choice and choice is that choice can return only one element at a time, and n elements can be returned at the same time in sample.
Random. uniform (start range, end range) is used to retrieve a floating point number within a specified range.
Random. shuffle is used to disrupt the order of elements in a sequence (this function directly modifies the original sequence .)
The above is a detailed description of the random module in python. For more information, see other related articles in the first PHP community!