from random import * def B(p): if random() < p: X = 1 else: X = 0 return X print(B(0.36))