Random module- Function in this module depend upon the pseudo random number generator function random.
random()- Generates a random float number 0.0 to 1.0.
e.g.,
import random random.random()
randint()- Returns a random integer between the specified integers.
syntax:-
import random random.randint(1,100)
randrange()- Returns a randomly selected element from the range.
e.g.,
import random random.randrange(1, 10, 2)
choice()- Returns a randomly selected element from non-empty sequence.
e.g.,
import random random.choice("pythonpoint")
shuffle()- Randomly reorders elements in a list.
syntax:-
import random a=[1, 2, 3, 4, 5, 6, 7, 8] random.shuffle(a) print(a)
This is all about random module in python.