1 Star 0 Fork 0

ChrisEighteen18/pySimpleGamePractice

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
dragon.py 1.23 KB
一键复制 编辑 原始数据 按行查看 历史
# 练习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()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/ChrisEighteen18/py-simple-game-practice.git
git@gitee.com:ChrisEighteen18/py-simple-game-practice.git
ChrisEighteen18
py-simple-game-practice
pySimpleGamePractice
master

搜索帮助