Space Has Numbers


Notice: Undefined variable: params in /home/rogerlov/public_html/blog/skins/print/index.main.php on line 63

Warning: array_merge(): Expected parameter 2 to be an array, null given in /home/rogerlov/public_html/blog/skins/print/index.main.php on line 63

Notice: Trying to access array offset on value of type null in /home/rogerlov/public_html/blog/skins/print/index.main.php on line 70

Notice: Trying to access array offset on value of type null in /home/rogerlov/public_html/blog/skins/print/index.main.php on line 80

Notice: Trying to access array offset on value of type null in /home/rogerlov/public_html/blog/skins/print/index.main.php on line 85

Notice: Trying to access array offset on value of type null in /home/rogerlov/public_html/blog/skins/print/index.main.php on line 91

Notice: Trying to access array offset on value of type null in /home/rogerlov/public_html/blog/skins/print/index.main.php on line 93
import random def birthdayMatched(members): numYearDa ys = 365 # Number of days s = range(numYearDays) matched = False membersList=[None] * members for i in range(members): membersList[i] = random.choice(s) if len(set(membersList)) < members : matched = True return matched def sim_birthdayMatched(numTrials): numMatches = 0 numPeopleInParty = 23 for i in range(numTrials): if birthdayMatched(numPeopleInParty): numMatches += 1 return numMatches/numTrials Call: The function takes the number of people as an input sim_birthdayMatched(10000) Output: 0.5077