Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How would I find the minimum number of classmates such that the probability of two or more people have a same birthday is at least
How would I find the minimum number of classmates such that the probability of two or more people have a same birthday is at least 50%. import random Birth = 25 numTrials = 1000 Dup = 0 for trial in range(numTrials): year = [0]*365 for i in range(Birth): newBDay = random.randrange(365) year[newBDay] = year[newBDay] + 1 DupMatch = False for num in year: if num > 1: DupMatch = True if DupMatch == True: Dup = Dup + 1 prob = Dup / numTrials print("The probability of a shared birthday in a class of ", Birth, " is ", prob)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started