Random integers produced by randrange. : random « Buildin Module « Python Tutorial






import random

for i in range( 1, 21 ):  # simulates 20 die rolls
   print "%10d" % ( random.randrange( 1, 7 ) ),
   if i % 5 == 0:  # print newline every 5 rolls
      print








14.11.random
14.11.1.Random integers produced by randrange.
14.11.2.Roll a six-sided die 6000 times.