Skip to content

Instantly share code, notes, and snippets.

@CodeMaster7000
Created January 1, 2022 21:52
Show Gist options
  • Select an option

  • Save CodeMaster7000/135c359a2fa8c934d396e60df853b7e9 to your computer and use it in GitHub Desktop.

Select an option

Save CodeMaster7000/135c359a2fa8c934d396e60df853b7e9 to your computer and use it in GitHub Desktop.
A Magic 8 Ball coded in Python 3 with the answers to all of your life questions!
import sys
import random
ans = True
while ans:
question = input("Ask our trustworthy Magic 8 ball a question: (press enter to quit) ")
answers = random.randint(1,20)
if question == "":
sys.exit()
elif answers == 1:
print("It is certain")
elif answers == 2:
print("It is decidedly so")
elif answers == 3:
print("Without a doubt")
elif answers == 4:
print("Yes definitely")
elif answers == 5:
print("You may rely on it")
elif answers == 6:
print("As I see it, yes")
elif answers == 7:
print("Most likely")
elif answers == 8:
print("Outlook good")
elif answers == 9:
print("Yes")
elif answers == 10:
print("Signs point to yes")
elif answers == 11:
print("Reply hazy, try again")
elif answers == 12:
print("Ask again later")
elif answers == 13:
print("Better not tell you now")
elif answers == 14:
print("Cannot predict now")
elif answers == 15:
print("Concentrate and ask again")
elif answers == 16:
print("Don't count on it")
elif answers == 17:
print("My reply is no")
elif answers == 18:
print("My sources say no")
elif answers == 19:
print("Outlook not so good")
elif answers == 20:
print("Very doubtful")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment