Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. import random
  2.  
  3. G="gold"
  4. S="silver"
  5. boxes=[[G,G],[G,S],[S,S]];
  6.  
  7. count = 0;
  8. count2 = 0;
  9. for i in xrange(100000):
  10.         box = random.choice(boxes)
  11.         i = random.randrange(2)
  12.         ball1 = box[i]
  13.         ball2 = box[i-1]
  14.         if (ball1 == G):
  15.                 count += 1
  16.                 if (ball2 == G):
  17.                         count2 += 1
  18.  
  19. print (1.0*count2)/(1.0*count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement