Python Program to Generate a Random Number – 2024

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

Abhishek Sharma
Abhishek Sharma

Started my Data Science journey in my 2nd year of college and since then continuously into it because of the magical powers of ML and continuously doing projects in almost every domain of AI like ML, DL, CV, NLP.

Articles: 517

Leave a Reply

Your email address will not be published. Required fields are marked *