In [ ]:
#Willio Charles
#magic 8ball will provide a answer to your question
     
#I am putting 3 functions from their respective libraries 

#randint() from the random library
from random import randint

#clear_output() from the IPython.display library (Jupyter Only)
from IPython.display import clear_output

#sleep() from the time library
from time import sleep

# I am showing the variables

#The response variable is a list that Holds all of the answers
response = ["As I see it, yes.", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.", "Don’t count on it.", "It is certain.", "It is decidedly so.", "Most likely.", "My reply is no.", "My sources say no.", "Outlook not so good.", "Outlook good.", "Reply hazy, try again.", "Signs point to yes.", "Very doubtful.", "Without a doubt.", "Yes.", "Yes - definitely.", "You may rely on it."] 


 #Exit function asking if I want to go again.
def leave():
    leaveQuestion = input("Do you want to ask agian? Y,y or N,n ==> ")
    leaveQuestion == "Y" or leaveQuestion == "y"

def main():

    leaveQuestion == "N" or leaveQuestion == "n"

    clear_output()
print("Have a Great day")


leave()

def main():

#sleep timer gives the 8ball time to think or generate answer 
 sleepTimer = randint(3, 6)    
    
responseItem = randint(0,19)
#input asking question
question = input("What question do you have for me, I will find out")
#If user keeps bar empty magic 8ball will answer because it will think its a secret question
if question == "":
    question = "Here is the answer to your secret question."
    
#clears the screen
clear_output()
    
print("I am getting your answer...")
    
#Im running the sleep command between 2 and 4 seconds because of the the sleepTimer variable

sleepTimer = randint(2,4)
    
clear_output()
    
#I print my answer using the \n in the print statement, that force a line break.
print("{} \n".format(question))
print(response[responseItem])
    
#I run the leave fuction so the user can quit
leave()

                 
main()
Here is the answer to your secret question. 

Outlook good.
In [ ]:
 
Home