-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboyorgirl.py
44 lines (30 loc) · 869 Bytes
/
boyorgirl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 10 09:57:01 2019
@author: abhisheklomsh
"""
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 8 11:48:12 2019
@author: abhisheklomsh
Here I am trying to generate number of girl children and boy children in a family where the couple will keep having children till a boy is born
I have checked it for 10000 families and the ratio of boy to girl is near to 1 that means nearly equal number of boys and girls are born
"""
import numpy as np
ans=0
result = []
for child in range(10000):
print(child)
ans=0
while(ans==0):
print("you got ",ans)
ans=np.random.randint(2)
print("you got ",ans)
result.append(ans)
girl=result.count(0)
boy=result.count(1)
print(result)
ratio= boy/girl
print(ratio)