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
Comments (0)