Skip to content

Instantly share code, notes, and snippets.

@santosh
Created May 9, 2018 02:33
Show Gist options
  • Save santosh/ffd870e4c918d946e830403cd2ed4e63 to your computer and use it in GitHub Desktop.
Save santosh/ffd870e4c918d946e830403cd2ed4e63 to your computer and use it in GitHub Desktop.
Random module use cases.
import random
print(random.sample(range(100), 5))
print(random.sample(["Fish", "Dog", "Cat"], 1))
print(random.choice(["Fish", "Dog", "Cat"]))
pets=["Fish", "Dog", "Cat", "Parrot"]
random.shuffle(pets)
print(pets)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment