Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import random, randint
- def create_siblings():
- # returns ((Child1, Day1), (Child2, Day2))
- # Child1 is True if first child is male
- # Day1 = 1 -> Monday, 2 -> Tuesday etc
- return ((random() < .5, randint(1, 7)), (random() < .5, randint(1, 7)))
- girl = 0
- boy = 0
- for i in range(100000000): #100kk simulations
- (c1, d1), (c2, d2) = create_siblings()
- if (c1 and d1==2) or (c2 and d2==2):
- if c1 == c2: # If both children are of the same gender (male)
- boy += 1
- else:
- girl += 1
- print("{} Boys, {} Girls, {} Ratio".format(boy, girl, boy/(boy+girl)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement