random module study notes

Import Random
 # generates random floating point number (0-1, no parameters) 
RFl = random.random ()  
 # generates a random floating point (specified section)   
RF2 = random.uniform (l, 4 )  
 # float retained specified number 
rf3 = round (random.uniform (l, 5), 2 )
 # generates a random integer (specified section) 
RF4 = the random.randint (20,500 )
 # returns a random number incrementing the cardinality of the set, the method: randrange () 
RF5 = random. randrange (10,40,2 ) 
RF6 = the random.choice (Range (10,40,2 ))
 # acquiring a random element from the sequence, the method: the random.choice (sequence) 
LIS1 = [23,44,5,7 , 2,2.3 ] 
TUP1 = (. 3, ' E ' , ' T ') 
RF7 = random.choice (TUP1) 
RF8 = random.choice (LIS1)
 # random order, assignment to print None? Modifies the original sequence 
random.shuffle (LIS1)
 Print (LIS1)         # RF9 = random.shuffle (LIS1) 
# random acquisition fragment specified length from the specified sequence and random arrangement. Function sample () Note: sample function does not modify the original sequence. 
= random.sample RF10 (lis1,3 )
 Print (LIS1)
 Print (RF10)

 



Guess you like

Origin www.cnblogs.com/duguxiren/p/11570565.html