python制作猜数小游戏
作者:互联网
"""用python设计一个游戏"""
import random //导入随机模块
counts = 3 //猜数游戏的次数
answer = random.randint(1,10) //采用随机数,猜数的范围
while counts > 0: //建立循环
temp = input("不妨猜一下我现在心里想的哪个数字:")
guess = int(temp)
if guess == answer:
print("你是我肚里的蛔虫吗?!")
print("哈哈,猜中也没奖励!")
break
else:
if guess < answer:
print("小啦小啦")
else:
print("大啦大啦")
counts = counts-1
print("游戏结束")
标签:guess,猜数,python,random,answer,小游戏,print,counts 来源: https://blog.csdn.net/ITwang1/article/details/120625596