Ask Your Question

Revision history [back]

/ acting like // ?

This script is meant to simulate rolling a fair die until a 6 occurs. I don't understand why at the very end my division of the sum of the rolls by the number of rolls is coming out the way it does. Thanks for your attention.

a=0;l=[];count=0;b=[] while count < 11: while a<6: a=choice([1..6]) l.append(a) print l count+=1 b.append(len(l)) a=0;l=[] s=sum(b);t=len(b) print "b= ",b,"Sum=",sum(b),"Throws=",len(b),"Sum/Throws=",s,"/",t,"=",s/t,N(s/t) print "Average over",len(b),"trials is",(sum(b)/len(b)) print "The type of sum(b) is",type(sum(b)),"The type of len(b) is",type(len(b))