from random import random def bernoulli(n,p): succes=0 for i in range(n): if random()>> bernoulli(100,0.8) 82