Guest User

something

a guest
Jan 10th, 2014
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import random
  2.  
  3. def randomDay():
  4.     return random.choice(('Mo','Tu','We','Th','Fr','Sa','Su'))
  5.  
  6. def randomSex():
  7.     return random.choice(('Male','Female'))
  8.  
  9. def main():
  10.  
  11.     boy=0
  12.     girl=0
  13.    
  14.     for i in range(0, 10000):
  15.        
  16.         c  = {"sex":randomSex(), "day":randomDay()}
  17.         c2 = {"sex":randomSex(), "day":randomDay()}
  18.  
  19.         if((c['sex'] == 'Male' and c['day'] == 'Tu') or (c2['sex'] == 'Male' and c2['day'] == 'Tu')):
  20.             if(c['sex'] == c2['sex']):
  21.                 boy  += 1
  22.             else:
  23.                 girl += 1
  24.  
  25.     print "ratio of boys to girls is " + str(boy) + ":" + str(girl)
  26.  
  27. if __name__ == '__main__':
  28.     main()
Advertisement
Add Comment
Please, Sign In to add comment