# The library required to generate random numbers import random
# Generate a random int between 1 and 10 random_integer = random.randint(1, 10)
# Print out the generated integer print(random_integer)
4
The Python randint() can generate random integers by getting as arguments the lower and the upper bound integers of the range you want the integer to be picked from.
Python Mega Course: Learn Python in 60 Days, Build 20 Apps
Learn Python on Udemy completely in 60 days or less by building 20 real-world applications from web development to data science.