20190810-random function usage summary

. 1  import random
 2      # using the random function introduced import module 
. 3 List1 the random.randint = (0,99 )
 . 4      # the random.randint: randomly selected integer between 0 and 99 
. 5  Print (List1)
 . 6  
. 7 List2 = random.randrange ( 0,100,3 )
 . 8      # random.randrange: randomly selected between 0 and 100 aliquot of 3 values 
. 9  Print (List2)
 10  
. 11 list3 = random.random ()
 12 is      # random.random: randomly selected between 0 and 1 float 
13 is  Print (list3)
 14  
15 list4 random.uniform = (2,30 )
 16      #random.uniform: randomly float between 0. 1 
. 17  Print (list4)
 18 is  
. 19 list5 The random.choice = ( ' weekend overtime Company ' )
 20 is  Print (list5)
 21 is A = The random.choice ([ ' Fairweather ' , ' Yi white ' , ' sub-ink ' , ' First sub ' ])
 22 is      # the random.choice: a randomly selected character string; Similarly, a string may be randomly selected, note: the list must be form 
23 is  Print ( ' Please name for extracting a small nine: {} ' .format (a))
 24  
25 a = ' Yi Mu ink albino Air' 
26 is list6 random.sample = (A, 2 )
 27      # random.sample: selecting a specific number (2) multi-character character 
28  Print ( ' randomly selected two characters as the name of small nine: {}, meaning good ' .format (list6))
 29  
30 list7 = [1,3,4,5,6 ]
 31 is  random.shuffle (list7)
 32      # random.shuffle: the digital list7 shuffling, random adjusted Note: list7 must be in the form of a list, when print print direct reference list list7. 
33 is  Print (list7)

 

Guess you like

Origin www.cnblogs.com/yssshiny/p/11331630.html