monte carlo simulation for exampleif you made pass line bets and won half of themyour roi would be = if you bet the don' pass line times and had wins and pushes the roi would be - - note that in crapssim we use xrange rather than range in the for loops in anticipation of running large simulations recall that in python range(ncreates sequence with elements whereas xrange(ngenerates the values only as they are needed by the for loop def crapssim(handspergamenumgames)"""assumes handspergame and numgames are ints play numgames games of handspergame handsand print results""games [#play numgames games for in xrange(numgames) crapsgame(for in xrange(handspergame) playhand(games append( #produce statistics for each game proipergamedproipergame [][for in gameswinslosses passresults(proipergame append((wins losses)/float(handspergame)winslossespushes dpresults(dproipergame append((wins losses)/float(handspergame)#produce and print summary statistics meanroi str(round(( *sum(proipergame)/numgames) )'%sigma str(round( *stddev(proipergame) )'%print 'pass:''mean roi ='meanroi'std dev ='sigma meanroi str(round(( *sum(dproipergame)/numgames) )'%sigma str(round( *stddev(dproipergame) )'%print 'don\' pass:','mean roi ='meanroi'std dev ='sigma figure simulating craps game let' run our craps simulation and see what happens: crapssim( passmean roi - std dev don' passmean roi std dev keep in mind that since these programs incorporate randomnessyou should not expect to get identical results if you run the code yourself more importantlydo not make any bets until you have read the entire section