Random integers produced by randrange. : Random « Development « Python






Random integers produced by randrange.

Random integers produced by randrange.
 
import random


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

           
         
  








Related examples in the same category

1.Demonstrates random number generation
2.random number generationrandom number generation
3.Random Choice Random Choice
4.Sampling without replacementSampling without replacement
5.Random int value
6.Random floatRandom float
7.Random string value
8.Demonstrates the range() functionDemonstrates the range() function
9.Random integer chosen from range(6)Random integer chosen from range(6)