Usage examples:
ImportRandom#1) Random decimalsPrint(Random.random ())#gets a decimal number greater than 0 and less than 1 random.random ()Print(Random.uniform (1, 4))#get a decimal greater than 1 less than 3#2) Random integersPrint(Random.randint (1, 9))#gets an integer greater than or equal to 1 and less than or equal to 9Print(Random.randrange (1, 9))#get an integer greater than or equal to 1 and less than 9Print(Random.randrange (1, 9, 2))#gets an odd number greater than or equal to 1 and less than 9#3) Randomly select a return valuePrint(Random.choice ([1,' at', [4, 5]]))#returns 1 or 23 or [1,5]#4) Randomly select multiple return values, the number returned is the second parameter of the functionPrint(Random.sample ([1,' at', [4, 5]],2)]#returns any 2 combinations of list elements as a list#5) Shuffle list orderLis = [1, 2, 3, 4, 5, 6]random.shuffle (LIS)#Shuffle Scramble OrderPrint(LIS) Lis1= [5, 1, 3, 7, 9]random.shuffle (LIS1)Print(LIS1)
>>>>>>>> generate random Verification code example
Python--random Module