0% found this document useful (0 votes)
92 views

Project #1 - Python Magic 8 Ball: Complete Python Programming Masterclass Beginner To Advanced

This document describes Project #1 for a Python programming course - building a Magic 8 Ball app. The app will prompt the user to ask a question, randomly select a response from a list of 8 possible answers, and print the response. It involves importing the random and sys modules, storing the possible responses, getting user input, randomly selecting and returning a response, and repeating in a loop until the user presses enter without input.

Uploaded by

NAMBURUNITHIN
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views

Project #1 - Python Magic 8 Ball: Complete Python Programming Masterclass Beginner To Advanced

This document describes Project #1 for a Python programming course - building a Magic 8 Ball app. The app will prompt the user to ask a question, randomly select a response from a list of 8 possible answers, and print the response. It involves importing the random and sys modules, storing the possible responses, getting user input, randomly selecting and returning a response, and repeating in a loop until the user presses enter without input.

Uploaded by

NAMBURUNITHIN
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

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.


o “sys” module and the “random” module
o You can read more on the “sys” module here:
https://docs.python.org/2/library/sys.html
o 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)
o 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.
o 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”
o 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.
************************** CODE SPOILER ************************

***************************************************************

***************************************************************

***************************************************************

***************************************************************

COMPLETED CODE IS FOUND ON THE NEXT PAGE

You might also like