random boolean with probability python code example Example: random boolean python import random bool(random.getrandbits(1))