代码拉取完成,页面将自动刷新
# 练习time 库和相关str 逻辑
import random
import time
# 说明信息
def showInfo():
print("You are in a land full of dragons. In front of you, you see two caves. In one cave, the dragon is friendly "
"\nand will share his treasure with you. The other dragon \n is greedy and hungry, and will eat you on "
"sight.\nWhich cave will you go into? (1 or 2)")
def friendlyCave():
return random.randint(0, 1)
def showCaveInfo():
print('You approach the cave...')
time.sleep(2)
print('It is dark and spooky...')
time.sleep(2)
print('A large dragon jumps out in front of you! He opens his jaws and...')
time.sleep(2)
def enterCave():
choice = input()
while choice != '1' and choice != '2':
print("Which cave will you go into? (1 or 2)")
choice = input()
choice = int(choice)
showCaveInfo()
if choice == friendlyCave():
print('Gives you his treasure!')
else:
print('Gobbles you down in one bite!')
def startGame():
showInfo()
enterCave()
if __name__ == '__main__':
begin = "y"
while begin == "yes" or begin == "y":
startGame()
print('Do you want to play again? (yes or no)')
begin = input().lower()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。