[Tutor] My first python program!
python_newbie at vedorian.com
Tue Aug 17 23:44:20 CEST 2004
Ya I when I copied and pastet the code I missed the import. As for the other
ones I forgot to chage the 100 to 10(It was a pain in the but trying to see
if the program worked starting from 1 and making my way to 100 lol.). Thanks
for the suggestions I will work on that and try and fix it.
----- Original Message -----
From: "Britt Green" <seamonkeys at gmail.com>
To: "Kevin" <python_newbie at vedorian.com>
Sent: Tuesday, August 17, 2004 5:34 PM
Subject: Re: [Tutor] My first python program!
> Hi Kevin,
> Your first program looks pretty good. A lot better than my first program!
> Anyways, here's some constructive criticism. I tried to run your
> program but got the error: NameError: global name 'randrange' is not
> defined. I'm guessing this is because you just forgot to include the
> import of the random module in the email. ;)
> In the game2() module, the player is first asked to pick a number from
> 1-10. But for every guess thereafter, they have to pick between 1-100!
> Eek! It could just be a typo, though.
> The serious bug I found in your program is that the game doesn't end
> after five rounds. It ends only when the player correctly guesses the
> right number. You should rewrite the while loop so it terminates when
> the number of guesses variable reaches five. Otherwise, your program
> is a great one, especially for a first attempt!
> ----- Original Message -----
> From: Kevin <python_newbie at vedorian.com>
> Date: Tue, 17 Aug 2004 15:31:47 -0400
> Subject: [Tutor] My first python program!
> To: Python <tutor at python.org>
> 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.
> def enter():
> print """
> * *
> * The Number Guessing Game *
> * By: Cadon *
> + Please enter a choice! +
> + 1) Enter game +
> + 2) Exit +
> enter = raw_input("What is your choice? ")
> if enter == '1':
> 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
> 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") )
> print "Congrats! that was the correct number!\r\n"
> ans = raw_input("Would you like to play again?[y/n]: ")
> if ans == 'y':
> print "Thank you for playing, come back
> 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
> Tutor maillist - Tutor at python.org
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
More information about the Tutor