import random
print ( “欢迎来到猜数字游戏” )
n = random.randint ( 1 , 1000 )
print ( n )
i = 1
while i <= 3 :
num = int ( input ( “请输入整数” ) )
if num > n :
print ( “大了” )
elif num < n :
print ( “小了” )
elif num == n :
print ( “祝贺” )
break
i += 1
if i > 3 :
print ( “超出次数,游戏结束” )
x = input ( “开始新的游戏吗(y/n):” )
if x == ‘y’ :
continue
else :
break