Complete Python Programming Masterclass Beginner to Advanced
Project #1 – Python Magic 8 Ball
This project will present you with the opportunity to apply the skills that you have learned up to this point with the course.
1.1BUILD A MAGIC 8 BALL APP IN PYTHON
This project will require you to create a single Python file (.py). You will find a file called, “PythonMagicBall-08-01.py” attached to this lecture. You can use this file as a starting point for the project.
The project will prompt the user to type a question. The code will then randomize a response and return (print) the response back to the user, based on 8 pre-defined response.
Step 1
Two modules will need to be imported into your Python file.
“sys” module and the “random” module
You can read more on the “sys” module here: https://docs.python.org/2/library/sys.html
You can read more on the “random” module here: https://docs.python.org/2/library/random.html
Research the two modules by using the “dir” function. Ex. dir(math)
Identify any of the attributes/functions that will help you in completing this project
Requirements
When a user runs the project, they should receive a prompt (printed message), asking them to ask the magic 8 ball a question.
The user will then type in a question and press the enter key.
Logic, built in the code, will then return a random response back to the user.
Valid random response will include:
§ “IT IS CERTAIN”
§ “YOU MAY RELY ON IT”
§ “AS I SEE IT, YES”
§ “OUTLOOK LOOKS GOOD”
§ “MOST LIKELY”
§ IT IS DECIDELY SO”
§ “WITHOUT A DOUBT”
§ “YES, DEFINETLY”
You can decide how to store the valid responses and how to randomly return on of the responses.
The program should continue to run in a loop, returning a random response for each question they user types.
If the user doesn’t enter a question and the presses the enter key, then the application should quit.