Python Tutorial Magic 8 Ball

This tutorial will show how to make a magic 8 ball program in python. This program will have the same functions as a magic 8 ball , the user will input a question and the 8-ball will generate a reply to the question.

The user’s input will by retrieved by using input() . Here is a link to a quick tutorial on the input() keyword in Python.

# Import  modules
import sys
import random

reply = True #If running

while reply:
    inputQuestion = input("Type 'quit' to exit... Ask magic 8 ball a question: ")

    response = random.randint(1, 8) 
    if inputQuestion == "quit":
        sys.exit() #exit program 

# List of random responses 
    elif response == 1:
        print("It is certain")
    elif response == 2:
        print("Don't count on it.")
    elif response == 3:
    elif response == 4:
        print("Ask again later")
    elif response == 5:
        print("Concentrate and ask again")
    elif response == 6:
        print("Reply hazy, try again")
    elif response == 7:
        print("As I see it, yes.")
    elif response == 8:
        print("It will not be so.")


Type 'quit' to exit..Ask magic 8 ball a question:  will i pass my test?
It is certain

Android Studio Loading Animation Between Activities

Progress Dialog is dialog showing a progress indicator and an optional text message or view. The methods of Progress Dialog being used in this tutorial are: ProgressDialog.setTitle() – Used to set title of dialog box ProgressDialog.setMessage() – Used to set dialog message being displayed ProgressDialog.setProgressStyle() – Choose the style of indicator ProgressDialog.dismiss() – Dismiss the … Read more Android Studio Loading Animation Between Activities

Android Studio Tutorial SeekBar

SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch thumb and drag left or right to set the current progress level or various other task. In this example, the seekbar will be used to display a percentage. As the user moves the SeekBar left to right the percentage value … Read more Android Studio Tutorial SeekBar

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s