代码拉取完成,页面将自动刷新
同步操作将从 jack2583/PythonExamples 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
'''Author Anurag Kumar(mailtoanuragkumarak95@gmail.com)
Module for implementing the simpest Magic 8 Ball Game.
Python:
- 3.5
Requirements:
- colorama
Usage:
- $python3 magic8ball.py
Ask a question, and know the future.
'''
from random import randint
from time import sleep
from colorama import Fore, Style
# response list..
response = [
"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",
"Quite possibly so",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Concentrate and ask again",
"Don't count on it",
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful"]
# core game...
def game():
ques = str(input("What is your question? \n").lower())
print("thinking...")
sleep(1)
idx = randint(0, 20)
if idx < 10:
color = Fore.GREEN
elif idx >= 10 and idx < 15:
color = Fore.YELLOW
else:
color = Fore.RED
print(color + response[idx] + Style.RESET_ALL + '\n\n')
playloop()
# looping func...
def playloop():
ques_again = str(input("Would you like to ask another question? (y/n)\n").lower())
if ques_again == 'y':
game()
elif ques_again == 'n':
print("Auf Wiedersehen!")
else:
print("What was that?/n")
playloop()
if __name__ == '__main__':
game()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。