Skip to content

Commit 692fe27

Browse files
authored
Create BIRTHDAY PARADOX USING PYTHON
THIS CODE IS MADE FOR BIRTHDAY PARADOX WHICH IS VERY INTERESTING.
1 parent d99f6d6 commit 692fe27

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

BIRTHDAY PARADOX USING PYTHON

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#birthday paradox
2+
import random
3+
import datetime
4+
birthday=[]
5+
i=0
6+
while(i<50):
7+
year=random.randint(2000,2010)
8+
if(year%4==0 and year%100!=0 or year%400==0):
9+
leap=1
10+
else:
11+
leap=0
12+
month=random.randint(1,12)
13+
if(month==2 and leap==1):
14+
day=random.randint(1,29)
15+
elif(month==2 and leap==0):
16+
day=random.randint(1,28)
17+
elif(month==7 or month==8):
18+
day=random.randint(1,31)
19+
elif(month%2!=0 and month<7):
20+
day=random.randint(1,31)
21+
elif(month%2!=0 and month>7 and month<12):
22+
day=random.randint(1,31)
23+
else:
24+
day=random.randint(1,30)
25+
dd=datetime.date(year,month,day)
26+
day_of_year=dd.timetuple().tm_yday
27+
i=i+1
28+
birthday.append(day_of_year)
29+
birthday.sort()
30+
i=0
31+
while(i<50):
32+
print(birthday[i])
33+
i=i+1

0 commit comments

Comments
 (0)