#------------------------------------------------------------------ # birthday.py # # This program shows the probabilities that among N people # selected at random, no two of them have the same birthday. # # execute using: $ python ./birthday.py # # programmer: ALLAN CRUSE # written on: 09 MAR 2011 #------------------------------------------------------------------ print print " Probabilities for the classic Birthday Problem " print print " In a randomly selected group of N people, what is" print " the probability that no two have the same birthday?" print probability = 1.0 for n in range( 30 ): probability *= (365.0 - n) / 365.0 print "\t N = %-2d\t probability = %1.3f " % (n+1, probability) print