cipheron

Birth Probabilities

Apr 10th, 2026 (edited)
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. import random
  2.  
  3. N = 10_000_000
  4. days = range(7)
  5. qualifies = other_is_girl = 0
  6.  
  7. for _ in range(N):
  8. c1 = (random.randint(0,1), random.choice(days))
  9. c2 = (random.randint(0,1), random.choice(days))
  10. if (c1[0]==1 and c1[1]==1) or (c2[0]==1 and c2[1]==1):
  11. qualifies += 1
  12. if (c1[0]==0 or c2[0]==0):
  13. other_is_girl += 1
  14.  
  15. print(f"{other_is_girl/qualifies:.4f}")
  16.  
Advertisement
Add Comment
Please, Sign In to add comment