Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'assignment': 0.07; 'directions': 0.09; 'exist,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:number': 0.09; 'subject:script': 0.09; 'variables.': 0.09; 'subject:Help': 0.11; 'python': 0.11; 'language.': 0.14; 'random': 0.14; 'conditional': 0.16; 'hint:': 0.16; 'i\xe2\x80\x99d': 0.16; 'i\xe2\x80\x99m': 0.16; 'loops': 0.16; 'made,': 0.16; 'main():': 0.16; 'message-id:@4ax.com': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'threw': 0.16; 'feb': 0.22; 'programming': 0.22; 'import': 0.22; 'print': 0.22; 'either.': 0.24; 'integer': 0.24; 'url:home': 0.24; 'skip:" 20': 0.27; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'point': 0.28; 'function': 0.29; "doesn't": 0.30; 'returned': 0.30; 'code': 0.31; '-0700,': 0.31; 'away.': 0.31; 'operators': 0.31; 'this.': 0.32; 'supposed': 0.32; 'fri,': 0.33; 'guess': 0.33; 'subject:the': 0.34; 'could': 0.34; 'subject:with': 0.35; 'common': 0.35; 'something': 0.35; 'but': 0.35; 'add': 0.35; 'returning': 0.36; 'skip:> 10': 0.36; 'project': 0.37; 'received:76': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'subject:" ': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'called': 0.40; 'how': 0.40; 'read': 0.60; 'number,': 0.60; 'tell': 0.60; 'new': 0.61; 'range': 0.61; "you're": 0.61; 'high': 0.63; 'within': 0.65; 'it!': 0.67; '>from': 0.68; 'secret': 0.74; 'can\xe2\x80\x99t': 0.84; 'confusing': 0.84; 'i\xe2\x80\x99ll': 0.84; 'mistakes': 0.93; 'scott': 0.93; 'hot': 0.96 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Help with "Guess the number" script Date: Sat, 01 Mar 2014 11:35:26 -0500 Organization: IISS Elusive Unicorn References: <43B63C46-3A2D-4374-8A42-EE931BA9A6C4@cox.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: adsl-76-249-31-118.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 68 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393691734 news.xs4all.nl 2830 [2001:888:2000:d::a6]:60275 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67319 On Fri, 28 Feb 2014 23:46:02 -0700, Scott W Dunning 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/