Python Program to Generate a Random Number – 2022

Machine Learning Projects

Hey guys, in this blog we will see a Python Program to Generate a Random Number using the random library of python.

Code

# Python Program to Generate Random Numbers

import random

print(random.randint(0,10))

Output

8

0

10

Here we are using the randint class of the random library of python which returns a random integer number in the range provided.

Both the numbers are inclusive in the range. This means in the example above it can return 0 and 10 also.

Check out our other python programming examples

Leave a Comment

Your email address will not be published.