1.自己输入数字
print("…………猜数字游戏…………")
temp = input("不妨猜一下我现在心里想的是哪个数字:")
guess = int(temp)
while guess != 8:
if guess > 8:
print ('大了')
temp = input ('重新输入:')
guess = int (temp)
else:
print ('小了')
temp = input ('重新输入:')
guess = int (temp)
print("卧槽,你是我心里的蛔虫吗?!")
print("哼,猜中了也没有奖励!")
print("游戏结束,不玩啦")
2.随机生成数字
import random
result = random.randint (1,10)
print("…………猜数字游戏…………")
temp = input("不妨猜一下我现在心里想的是哪个数字:")
guess = int(temp)
while guess != result:
if guess > result:
print ('大了')
temp = input ('重新输入:')
guess = int (temp)
else:
print ('小了')
temp = input ('重新输入:')
guess = int (temp)
print("卧槽,你是我心里的蛔虫吗?!")
print("哼,猜中了也没有奖励!")
print("游戏结束,不玩啦")