find random number in python code example
Example 1: generate random number python
import random
random.randint(lower, upper)
Example 2: how to get random number python
import random
minimum_int, maximum_int = 0, 10
random_number = random.randint(minimum_int, maximum_int)
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)
Example 4: generate random number python
import random
lower_limit = 0
upper_limit = 100
print(f"Here is a random number: {random.randint(lower_limit, upper_limit)}