Ai
1 Star 0 Fork 0

Role/Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
magic8ball.py 883 Bytes
一键复制 编辑 原始数据 按行查看 历史
Pinki Saha 提交于 2020-10-31 11:40 +08:00 . Added Magic 8 ball game
import random
responses = ['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','Do not count on it','My reply is no',' My sources say no',' Outlook not so good','Very doubtful', 'Reply hazy try again','Ask again later','Better not tell you now ','Cannot predict now ','Concentrate and ask again']
print("Hi! I am the magic 8 ball, what's your name?")
name = input()
print("Hello!"+ name)
def magic8Ball():
print("Whay's your question? ")
question = input()
answer = responses[random.randint(0,len(responses)-1)]
print(answer)
tryAgain()
def tryAgain():
print("Do you wanna ask any more questions? press Y for yes and any other key to exit ")
x = input()
if(x == 'Y'):
magic8Ball()
else:
exit()
magic8Ball()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/CRole/Python.git
git@gitee.com:CRole/Python.git
CRole
Python
Python
master

搜索帮助