Friday, January 3, 2014

Generate random number in Python

To generate random number in Python Shell:
>>> import random
>>> random.randint(0, 10)

generate random number in Python Shell
Generate random number in Python Shell

Code example:
#generate random 5 number
import random
for x in range(0, 5):
    random_number = random.randint(0, 10)
    print(random_number)

Python code to generate random number
Python code to generate random number

Output
Output