猜数字游戏

jici = 1
while jici:
  import random, easygui
  secret = random.randint(1,99)
  guess = 0
  tries = 1
  easygui.msgbox("我已经藏好了一个100内的数,给你6次机会,你猜猜!")
  guess = easygui.integerbox("填入你猜的数:")
  while guess != secret and tries < 6:
    jihui = 6 - tries
    if guess < secret:
      easygui.msgbox(str(guess)+ "小啦,你还有%d次机会" %jihui)
    elif guess > secret:
      easygui.msgbox(str(guess)+ "大啦,你还有%d次机会" %jihui)
    guess = easygui.integerbox("再填入你猜的数:")
    tries += 1
  if guess == secret:
    easygui.msgbox("恭喜,猜对了,我藏的数正是%d!" % secret)
  else:
    easygui.msgbox("笨死了,我藏的数是%d啦!" % secret)
  flavor = easygui.buttonbox("还继续玩吗?",choices = ['继续','不玩啦'])
  if flavor == '继续':
    print("继续")
  else:
    print("拜拜")
    jici = 0

posted @ 2018-01-14 17:09  阿龙3953  阅读(157)  评论(0)    收藏  举报