#Make a Magic 8 ball
#https://github.com/viljow/magic8/blob/master/main.py
import random
answers = ['It is certain', 'It is decidedly so', 'Without a doubt', 'Yes – definitely', 'You may rely on it', 'As I see it, yes', 'Most likely', 'Outlook good', 'Yes Signs point to yes', 'Reply hazy', 'try again', 'Ask again later', 'Better not tell you now', 'Cannot predict now', 'Concentrate and ask again', 'Dont count on it', 'My reply is no', 'My sources say no', 'Outlook not so good', 'Very doubtful']
print(' __ __ _____ _____ _____ ___ ')
print(' | \/ | /\ / ____|_ _/ ____| / _ \ ')
print(' | \ / | / \ | | __ | || | | (_) |')
print(' | |\/| | / /\ \| | |_ | | || | > _ < ')
print(' | | | |/ ____ \ |__| |_| || |____ | (_) |')
print(' |_| |_/_/ \_\_____|_____\_____| \___/ ')
print('')
print('')
print('')
print('Hello World, I am the Magic 8 Ball, What is your name?')
name = input()
print('hello ' + name)
def Magic8Ball():
print('Ask me a question.')
input()
print (answers[random.randint(0, len(answers)-1)] )
print('I hope that helped!')
Replay()
def Replay():
print ('Do you have another question? [Y/N] ')
reply = input()
if reply == 'Y':
Magic8Ball()
elif reply == 'N':
exit()
else:
print('I apologies, I did not catch that. Please repeat.')
Replay()
Magic8Ball()
Output:
__ __ _____ _____ _____ ___
| \/ | /\ / ____|_ _/ ____| / _ \
| \ / | / \ | | __ | || | | (_) |
| |\/| | / /\ \| | |_ | | || | > _ <
| | | |/ ____ \ |__| |_| || |____ | (_) |
|_| |_/_/ \_\_____|_____\_____| \___/
Hello World, I am the Magic 8 Ball, What is your name?
Sara
hello Sara
Ask me a question.
Tell my fortune
It is certain
I hope that helped!
Do you have another question? [Y/N]
Y
Ask me a question.
My favorite color
My reply is no
I hope that helped!
Do you have another question? [Y/N]
N
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer