Random integers:
>>> Import random>>> random.randint (0,99) 21
Randomly select even numbers between 0 and 100:
>>> Import random>>> random.randrange (0, 101, 2) 42
Random floating point number:
>>> import random>>> random.random () 0.85415370477785668>>> random.uniform (1, 10) 5.4221167969800881
Random characters:
>>> Import random>>> random.choice (' abcdefg&#%^*f ') ' d '
Select a specific number of characters in more than one character:
>>> Import randomrandom.sample (' Abcdefghij ', 3) [' A ', ' d ', ' B ']
Select a specific number of characters to form a new string in multiple characters:
>>> Import random>>> Import string>>> string.join (Random.sample ([' A ', ' B ', ' C ', ' d ', ' e ', ' f ') , ' g ', ' h ', ' I ', ' J '], 3). Replace ("", "") ' FIH '
Randomly pick a string:
>>> Import random>>> random.choice ([' Apple ', ' pear ', ' peach ', ' orange ', ' lemon ') ' Lemon '
Shuffle:
>>> Import random>>> items = [1, 2, 3, 4, 5, 6]>>> random.shuffle (items) >>> items[3, 2 , 5, 6, 4, 1]
There are a lot of random functions, not listed here,