import randomfrequency1 = 0frequency2 = 0frequency3 = 0frequency4 = 0frequency5 = 0frequency6 = 0for roll in range( 1, 6001 ): # 6000 die rolls face = random.randrange( 1, 7 ) if face == 1: # frequency counted frequency1 += 1 elif face == 2: frequency2 += 1 elif face == 3: frequency3 += 1 elif face == 4: frequency4 += 1 elif face == 5: frequency5 += 1 elif face == 6: frequency6 += 1 else: # simple error handling print "should never get here!"print "Face %13s" % "Frequency"print " 1 %13d" % frequency1print " 2 %13d" % frequency2print " 3 %13d" % frequency3print " 4 %13d" % frequency4print " 5 %13d" % frequency5print " 6 %13d" % frequency6
Name (required)
email (will not be published) (required)
Website