All pastes #245089 Raw Edit

Someone

public text v1 · immutable
#245089 ·published 2006-11-10 16:32 UTC
rendered paste body
#!/usr/bin/python

def message(x):
  if x == 1:
    print "The number is greater"
  elif x == 0:
    print "Congratulations, you have found the number!!!"
  elif x == -1:
    print "The number is smaller"
  else:
    print "Error"

def game():
  '''The main game'''
  #Select a number
  import random
  num = random.randrange(0,100)

  #Check the given number
  for i in range(5):
    inum = asknumber()
    if inum == num:
      message(0)
      break
    elif inum > num:
      message(-1)
    elif inum < num:
      message(1)

def asknumber():
  print "Please give a number:"
  inum = int(raw_input())
  return inum