美文网首页
python学习第一弹 猜数字游戏

python学习第一弹 猜数字游戏

作者: 月白风清L | 来源:发表于2017-10-23 15:11 被阅读0次

闲话不说贴代码(就不写什么HelloWorld了,太low没脸写)


importrandom

secret = random.randint(1,100)# create a random number

print(secret)

time =9# the time of guess

guess =0# the number input

minNum =0

maxNum =100

print('===============>猜数字游戏开始啦!')

whileguess != secretandtime >=0:

guess =int(input("*Please input number between 0-100:"))

# print("Your number is :",guess)

ifguess == secret:

print("Great!you are right")

else:

ifguess < secret:

minNum = guess

print("Your number is less than answer")

print("Now,the range of number is:",minNum,"-",maxNum)

else:

maxNum = guess

print("Your number is max than answer")

print("Now,the range of number is:",minNum,"-",maxNum)

print("You are wrong,you have ",time,"times")

time -=1

print('Game over! the answer is :',secret)

相关文章

网友评论

      本文标题:python学习第一弹 猜数字游戏

      本文链接:https://www.haomeiwen.com/subject/gzrauxtx.html