Sabari M Sabari M
Updated date Feb 23, 2021
This code snippet shows how to generate a random number in python using the in-build python method.

This code snippet shows how to generate a random number in python using the in-build python method.

We can easily generate a random number in python using the in-built method randint(a,b). This method is used to generate a random number within a range provided.

Syntax:

random.randint(a,b)

In order to use this randint(a,b) method, you have to import random module as shown below,

# importing the random module
import random

print(random.randint(0,100))

Output:

In the above example, we have provided the range between 0 to 100. So the python will generate the random number between 0 to 100.

54

 

ABOUT THE AUTHOR

Sabari M
Sabari M
Software Professional, India

IT professional with 14+ years of experience in Microsoft Technologies with a strong base in Microsoft .NET (C#.Net, ASP.Net MVC, ASP.NET WEB API, Webservices,...Read More

https://www.techieclues.com/profile/alagu-mano-sabari-m

Comments (0)

There are no comments. Be the first to comment!!!