How can we generate random numbers in python using methods? code example
Example 1: python random
import random
print(random.randint(1, 100))
Example 2: how to tell python to create a random numer
import random
print(random.randint(1, 100))
Example 3: how to call a random function in python
import random
my_list = [func_test_1, func_test_2, func_test_3]
random.choice(my_list)()
Example 4: 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)