fastread homefastrread library fastread menu

Python : Generate a Random Number

Tutorial by:Rizwan Abdullah      Date: 2016-06-16 00:45:45

❰ Previous Next ❱

Source Code


# Program to generate a random number between 0 and 9

# import the random module
import random

print(random.randint(0,9))

Output


5

In this program, we use the randint() function inside the random module. Note that, we may get different output because this program generates random number in range 0 and 9. The syntax of this function is:

random.randint(a,b)

 This returns a number N in the inclusive range [a,b], meaning a <= N <= b, where the endpoints are included in the range.

❰ Previous Next ❱


Python

Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website