[Tutor] My first python program!

Kevin python_newbie at vedorian.com
Tue Aug 17 21:31:47 CEST 2004


The programm looks a little messed up in email but it looks fine in IDLE
But here is the number guessing I just made as my very first programm.
Any suggestions on how to improve it would be greate.

Kevin

def enter():
  print """ 
   ***************************************
   *                                     *
          *     The Number Guessing Game        *
          *     By: Cadon                       *
          ***************************************
   |||||||||||||||||||||||||||||||||||||||
   +       Please enter a choice!        +
   +       1) Enter game                 +
   +       2) Exit                       +
   +++++++++++++++++++++++++++++++++++++++\r\n"""
  enter = raw_input("What is your choice? ")
  if enter == '1':
      game()
  else:
      print '\r\nThank you from looking at the game!'
    
    
def game():
  print "welcome to the number guessing game!\r\n"
  name = raw_input("What is your name? \r\n")
  print "Thank you %s, lets continue to the game now!\r\n" % name
                game2()
def game2():
  a = randrange(1, 10)
  guess = int(raw_input("Pick a number from 1 to 10, You only get 5 tries!: \r\n") )
  while guess != a:
      print "Thats not it!\r\n"
      guess = int(raw_input("Pick a number from 1 to 100, You only get 5 tries!: \r\n") )
  else:
      print "Congrats! that was the correct number!\r\n"
      ans = raw_input("Would you like to play again?[y/n]: ")
      if ans == 'y':
                        game2()
                    else:
                        print "Thank you for playing, come back again!\r\n"
      

enter()




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.726 / Virus Database: 481 - Release Date: 7/22/04
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20040817/6a63dc45/attachment.html


More information about the Tutor mailing list