1 Star 0 Fork 0

ChrisEighteen18/pySimpleGamePractice

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
guess.py 939 Bytes
一键复制 编辑 原始数据 按行查看 历史
# 练习python 的游戏编程
import random
currentTimes = 0
minNumber = 1
maxNumber = 20
guessMaxTimes = 6
guessNumber = random.randint(minNumber,maxNumber)
print("What is your name ?")
userName = input()
print("Heyy,{}~Let \'s go to guess a number between {} and {}.".format(userName,minNumber,maxNumber))
while currentTimes < guessMaxTimes:
# 次数加一
currentTimes = currentTimes + 1
if currentTimes >= guessMaxTimes:
print("The times area over!")
break
print("Please input a number between {} and {}.".format(minNumber,maxNumber));
currentNum = int(input())
if currentNum == guessNumber:
print("Congratulations! You\' re right ~ {}".format(userName))
break
elif currentNum > guessNumber:
print("Your number is higher than guess number~",end=userName)
elif currentNum < guessNumber:
print("Your number is lower than guess number~",end=userName)
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

搜索帮助