
January 11th, 2013, 01:41 PM
|
 |
Contributing User
|
|
|
|
Monte-Carlo simulation of some sort of situation.
Code:
import random
L = []
while len(L) < 100:
(n, count,) = (9999, 0,)
while n:
count += 1
n = random.randrange(n)
L.append(count)
print('mean number of trials: %g'%(sum(L)/float(len(L))))
__________________
[code] Code tags[/code] are essential for python code!
|