Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def randomDay():
- return random.choice(('Mo','Tu','We','Th','Fr','Sa','Su'))
- def randomSex():
- return random.choice(('Male','Female'))
- def main():
- boy=0
- girl=0
- for i in range(0, 10000):
- c = {"sex":randomSex(), "day":randomDay()}
- c2 = {"sex":randomSex(), "day":randomDay()}
- if((c['sex'] == 'Male' and c['day'] == 'Tu') or (c2['sex'] == 'Male' and c2['day'] == 'Tu')):
- if(c['sex'] == c2['sex']):
- boy += 1
- else:
- girl += 1
- print "ratio of boys to girls is " + str(boy) + ":" + str(girl)
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment