#------------------------------------------------------------------ # demere.py # # Compute the probability of getting "double-six" at least # once during twenty-four throws of a pair of 'fair' dice. # # execute using: $ python demere.py # # programmer: ALLAN CRUSE # written on: 06 JAN 2011 #------------------------------------------------------------------ print "\n\n When tossing a pair of dice twenty-four times ... " samples = 36 ** 24 print "\n size of the sample space: %d outcomes \n" % samples failures = 35 ** 24 print " 'double-six' does NOT occur in %d cases \n" % failures successes = samples - failures print " So odds in favor of getting 'double-six' at least once", print "in twenty-four throws: " print " %d:%d \n" % (successes, failures) probability = 1.0 - (1.0 * failures)/(1.0 * samples) print " Hence probability of getting 'double-six' at least once", print "in 24 throws = %1.4f \n\n" % probability