Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #67319

Re: Help with "Guess the number" script

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Help with "Guess the number" script
Date 2014-03-01 11:35 -0500
Organization IISS Elusive Unicorn
References <43B63C46-3A2D-4374-8A42-EE931BA9A6C4@cox.net>
Newsgroups comp.lang.python
Message-ID <mailman.7516.1393691734.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, 28 Feb 2014 23:46:02 -0700, Scott W Dunning <swdunning@cox.net>
declaimed the following:

>Hello, i am working on a project for learning python and I’m stuck.  The directions are confusing me.  Please keep in mind I’m very ne to this.  The directions are long so I’ll just add the paragraphs I’m confused about and my code if someone could help me out I’d greatly appreciate it!  Also, we haven’t learned loops yet so just
conditional operators and for some reason we can’t use global variables.  
>
	Without loops, one part of your assignment is going to be tedious,
unless the intent is to only allow for one guess per run.

>
>from random import randrange
>randrange(1, 101)

	You generated a random number and then threw it away.
>
>from random import seed
>seed(129)

	Now you are seeding the random number generator but never generate a
new number after it.

>    
>def print_description():
>    print """Welcome to Guess the Number.
>    I have seleted a secret number in the range 1 ... 100.
>    You must guess the number within 10 tries.
>    I will tell you if you ar high or low, and
>    I will tell you if you are hot or cold.\n"""
>   
>def get_guess(guess_number):
>    print "(",guess_number,")""Plese enter a guess:"
>    current_guess = raw_input()
>    return int(guess_number)

	You're returning the counter of how many guesses have been made, and
dropping the player's guess into the trash

>
>def main():
>    print_description()
>    secret = 50

	That's supposed to be the random number, isn't it?

>    current_guess = 1
>    get_guess(1)

	You drop the return value into the trash

>    if current_guess != secret():

	You are /calling/ a function called secret -- which doesn't exist,
since you bound it to the integer value 50; And current_guess doesn't exist
in this function either.

>        print "Congratulations you win!!"


	Read the documentation on how function calls and return values operate.
Hint: you need to do something with the returned value /at the point where
you call the function/.

	And -- as has been mentioned; these mistakes are better served in the
tutor list, as they would be mistakes in /any/ common programming language.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Help with "Guess the number" script Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-03-01 11:35 -0500
  Re: Help with "Guess the number" script Susan Aldridge <susanaldridge555@gmail.com> - 2014-03-01 10:03 -0800
  Re: Help with "Guess the number" script Scott W Dunning <swdunning@cox.net> - 2014-03-01 18:11 -0700
    Re: Help with "Guess the number" script Larry Hudson <orgnut@yahoo.com> - 2014-03-01 23:38 -0800
    Re: Help with "Guess the number" script Scott W Dunning <swdunning@cox.net> - 2014-03-02 18:36 -0700
  Re: Help with "Guess the number" script Chris Angelico <rosuav@gmail.com> - 2014-03-02 12:16 +1100
  Re: Help with "Guess the number" script Scott W Dunning <swdunning@cox.net> - 2014-03-02 18:40 -0700
  Re: Help with "Guess the number" script Scott W Dunning <swdunning@cox.net> - 2014-03-02 20:44 -0700
  Re: Help with "Guess the number" script Ben Finney <ben+python@benfinney.id.au> - 2014-03-03 14:52 +1100
  Re: Help with "Guess the number" script Scott W Dunning <swdunning@cox.net> - 2014-03-02 21:04 -0700
  Re: Help with "Guess the number" script Dave Angel <davea@davea.name> - 2014-03-03 02:10 -0500

csiph-web