# This program simulates the DeMere2 procedure in # Example 1.3 of Section 1.1 of the textbook: in 24 # rolls of two dice, what is the probability of # getting at least one pair of sixes? import random def demere(): v = [(random.randint(1,6),random.randint(1,6)) for _ in range(24)] return ((6,6) in v) def simulate(n): count = 0. for _ in range(n): if demere(): count += 1 return count/n print simulate(10000)