Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- # rand 0 to 1
- # -----------------
- # myRand = random.random()
- # print(myRand)
- # rand 0 to 1 int
- # -----------------
- # myRand = random.randint(1,12)
- # print(myRand)
- # rand array
- # --------------
- # myArr = ['python', 'js', 'php', 'c#']
- # myRand = random.choice(myArr)
- # print(myRand)
- # rand list
- # ---------------
- # myArr = ['python', 'js', 'php', 'c#']
- # myRand = random.choices(myArr, k=4)
- # print(myRand)
- # shuffle
- # --------------
- # myRand = list(range(1, 11))
- # random.shuffle(myRand)
- # print(myRand)
- # random unique value
- # --------------------
- myArr = list(range(1, 21))
- uniqueRand = random.sample(myArr, k=6) # random unique 6 value in list
- print(uniqueRand)
- # ------------------
- # more on documentation
- #-------------------
Advertisement
Add Comment
Please, Sign In to add comment