-8

I want to have Python print "Yes" 70% of the time, and "No" 30% of the time. How should I go about doing so?

1 Answers1

3

You can use the random module:

from random import random
while True:
    prob = random()
    if prob >= 0.3:
        print("Yes")
    else:
        print("No")
Jacob
  • 225
  • 1
  • 9