"""用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("游戏结束")