title: Probability Simulation in Python
body: <p>I was given a probability problem, and I wrote a script to test it.</p>
  
  <p>Two unbiased dice are thrown once and the total score is observe. Find de probabiity that:
   a) The total score is even or greater than 7</p>
  
  <p>I wrote the following script in Python, and it should give me the probability of "A" correct.</p>
  
  <pre><code>import random
  
  def thing(trials):
  
      i = 0
      number = 0
  
      while i &lt; trials:
  
          answer1 = random.choice([1, 2, 3, 4, 5, 6])
          answer2 = random.choice([1, 2, 3, 4, 5, 6])
  
  
          if (answer1 + answer2)%2 == 0:
              number += 1.0
          elif (answer1 + answer2) &gt; 7:
              number += 1.0
  
          i += 1
  
      print number/i
  </code></pre>
  
  <p>This gives me 2/3 as the answer, which <strong>is</strong> correct. Thanks!</p>