python猜数字小游戏
print("---------guess number--------") temp = input("please input you number :") guess = int(temp) num = 1 number = int(num) while (guess !=8) and (number != 3): temp = input("erro,please input you number :")
if guess == 8: print("ok") else: if guess > 8: print("litter big") number = number + 1 else: if guess < 8: print("a litter") number = number + 1 print("game over!")
续(随机生成数字匹配)
import random secret = random.randint(1,10) print("---------guess number--------") #temp = input("please input you number :") guess = secret #num = 1 #number = int(num) while guess !=8: # temp = input("erro,please input you number :") guess = random.randint(1,10) if guess == 8: print("ok,the number is :") print(guess) break else: if guess > 8: print("litter big") # number = number + 1 else: if guess < 8: print("a litter") # number = number + 1 print("game over!")