Skip to content

Instantly share code, notes, and snippets.

@Manikant92
Created July 21, 2018 06:06
Show Gist options
  • Save Manikant92/5efd642a5ca9a58dc2eb6c77e2c6535f to your computer and use it in GitHub Desktop.
Save Manikant92/5efd642a5ca9a58dc2eb6c77e2c6535f to your computer and use it in GitHub Desktop.
import random
random.seed(3)
#a with random seed number
a = [random.randint(1, 100) for i in range(10)]
print(a)
#output-1 when run first time: [61, 35, 85, 68, 86, 45, 19, 49, 2, 48]
#output-2 when run second time: [61, 35, 85, 68, 86, 45, 19, 49, 2, 48]
#b without random seed number
b = [random.randint(1, 100) for j in range(10)]
print(b)
#output-1 when run first time: [80, 19, 57, 48, 21, 44, 27, 8, 74, 26]
#output-2 when run second time: [10, 66, 88, 44, 88, 52, 12, 3, 8, 85]
random.seed(1)
a = [random.randint(1, 100) for j in range(10)]
#output-1: [18, 73, 98, 9, 33, 16, 64, 98, 58, 61]
#output-2: [18, 73, 98, 9, 33, 16, 64, 98, 58, 61]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment