Create a Program That Would Do The Following
1. Ask the user in shell “Ask yes or no question: ”
2. Pick a random number between 1 to 3.
3. If computer pick 1, print “Yes”.
4. If computer pick 2, print “Maybe”.
5. If computer pick 3, print “No”.
6. Repeat/continuously ask the user until the user enters “quit”.
The program will do the following
Ask yes or no question? Is it cloudy outside? Maybe Ask yes or no question? Is the wall red? Maybe Ask yes or no question? I am fat? Yes Ask yes or no question? quit
Solution
import random while True: user_input = input('Ask yes or no question? ') if user_input == 'quit': break num = random.randint(1,3) if num == 1: print('Yes') elif num == 2: print('Maybe') elif num == 3: print('No')