Adobe interview question

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