Adobe Interview Question

How do you simulate a bernoulli event with a probability p on the computer?