Untitled

 avatar
unknown
python
9 hours ago
809 B
8
Indexable


import random

bdays = int(input("How Many People To Generate ?"))


import datetime

Totalt=datetime.timedelta(days=365)
tas = Totalt.total_seconds()
ta = int(tas)
Bda=[]
for i in range(bdays):
    for j in range(10000):
        datetimeobj5=datetime.datetime.fromtimestamp(random.randint(0, ta))
        this = datetimeobj5.strftime("%b-%d")
        Bda.append(this)
#print(Bda)

# just find the date with maximum occurence and how many time it occured so that no./Total * 100
Countss = {}
for da in Bda:
    cos = Bda.count(da)
    Countss[da]=cos


#print(Countss)
def maxv(x):
    return x
maxxx = max(list(Countss.values()), key=maxv)*100
print(maxxx)
div = bdays*10000
thss = maxxx/div
print(f"{thss} is the percentage {bdays} person can have same bday")




Editor is loading...
Leave a Comment