random nums from selection in python code example
Example 1: n random numbers python
>>> import random
>>> random.sample(range(1, 100), 3)
[77, 52, 45]
Example 2: get n random numbers from x to y python
import random
random.sample(range(31), 10)
Example 3: random numbers python
import numpy
x = numpy.random.randint(100)
x = numpy.random.randint(100, size=5)
x = numpy.random.rand()
x = numpy.random.rand(5)
x = numpy.random.rand(2,3)
x = numpy.random.choice([1,5,2,3,4])
x = numpy.random.choice([1,5,2,3,4], size=(2,3))
import random
x = random.getrandbits(1)