+ 5
Create a Python project of a Magic 8 Ball which is a toy used for fortune-telling or seeking advice.
1) Allow the user to input their question. 2) Show an in progress message. 3) Create 10/20 responses, and show a random response. 4) Allow the user to ask another question/advice or quit the game.
3 odpowiedzi
+ 3
Are you asking if it's possible?
Very possible. Good luck with your project.
0
# Make a Magic 8 ball
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('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()
0
Create a Python project of a Magic 8 Ball which is a toy used for fortune-telling or seeking advice.
Allow the user to input their question.
Show an in progress message.
Create 10/20 responses, and show a random response.
Allow the user to ask another question/advice or quit the game.