Q:

n random numbers python

>>> import random
>>> random.sample(range(1, 100), 3)
[77, 52, 45]
1
import random
n = random.randint(0,22)
print(n)

# Output: 2
1
import random
n = random.randint(0,22)
print(n)
3
import random
a = (random.randint(bottom value, top value)
3
import numpy
x = numpy.random.randint(100)
# 63

x = numpy.random.randint(100, size=5)
# [60 50 55 30 88]

x = numpy.random.rand()
# 0.37588774033323125

x = numpy.random.rand(5)
# [0.41746837 0.67201216 0.55337301 0.51383033 0.21457139]

x = numpy.random.rand(2,3)
# [[0.19597024 0.65582147 0.3804617 ]
#  [0.5601902  0.5976546  0.58099592]]

x = numpy.random.choice([1,5,2,3,4])
# 3

x = numpy.random.choice([1,5,2,3,4], size=(2,3))
# [[2 4 1]
#  [3 3 3]]

import random
x = random.getrandbits(1)
# True
0

New to Communities?

Join the community