Question
IN PYTHON Goal: function and list of strings You are going to create a program that will mimic a Magic 8 Ball (toy used to
IN PYTHON
Goal: function and list of strings
You are going to create a program that will mimic a Magic 8 Ball (toy used to predict the future). The Magic 8 Ball had the following 12 responses:
Yes, of course!
Without a doubt, yes.
You can count on it.
For sure!
Ask me later.
Im not sure.
I cant tell you right now.
Ill tell you after my nap.
No way!
I dont think so.
Without a doubt, no.
The answer is clearly NO.
Your program should have a main function and one other function that will create a list of responses. The function that will create a list of responses should accept no parameters and return a list of 14 strings, the 12 given above plus two responses of your own. In this function, you should create an empty list, then use a loop to prompt the user to enter a string and append this string to the empty list. Once filled, the list should be returned to the function call.
Your main function should call the function to fill the list of responses. Prompt the user to enter a question. Then a random integer number between 0 and 13 (including 0 and 13) should be generated. Use this random number to determine a corresponding response from the list to the users question. For example if the random number was 4, the corresponding response would be Ask me later. Output both the users question and theMagic 8 Ball response. Allow the user to continue asking the Magic 8 Ball a question as long as he/she would like.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started