Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'argument': 0.05; 'assign': 0.07; 'matches': 0.07; 'arguments': 0.09; 'converted': 0.09; 'directions': 0.09; 'function,': 0.09; 'main()': 0.09; 'parameter': 0.09; 'subject:number': 0.09; 'subject:script': 0.09; 'variables.': 0.09; 'subject:Help': 0.11; 'python': 0.11; 'def': 0.12; 'random': 0.14; '(1,': 0.16; '...,': 0.16; 'attempt.': 0.16; 'conditional': 0.16; 'integer.': 0.16; 'loops': 0.16; 'main():': 0.16; 'parameter.': 0.16; 'variable.': 0.16; 'index': 0.16; 'variable': 0.18; 'received:10.0.1': 0.19; 'entered': 0.20; 'not,': 0.20; 'input': 0.22; 'import': 0.22; 'print': 0.22; 'define': 0.26; 'pass': 0.26; 'skip:" 20': 0.27; 'function': 0.29; 'correct': 0.29; 'statement': 0.30; 'code': 0.31; 'correctly.': 0.31; 'description,': 0.31; 'operators': 0.31; 'this.': 0.32; 'run': 0.32; 'guess': 0.33; 'raw': 0.33; 'subject:the': 0.34; 'could': 0.34; 'subject:with': 0.35; 'add': 0.35; 'doing': 0.36; 'thanks': 0.36; 'received:10.0': 0.36; 'should': 0.36; 'two': 0.37; 'project': 0.37; 'received:10': 0.37; 'little': 0.38; 'does': 0.39; 'subject:" ': 0.39; 'sure': 0.39; 'skip:p 20': 0.39; '8bit%:6': 0.40; 'number,': 0.60; 'tell': 0.60; 'lost': 0.61; 'new': 0.61; 'range': 0.61; 'header:Message-Id:1': 0.63; 'name': 0.63; 'high': 0.63; 'charset:windows-1252': 0.65; 'within': 0.65; 'here': 0.66; 'between': 0.67; 'it!': 0.67; 'user,': 0.69; 'online': 0.71; 'secret': 0.74; 'confusing': 0.84; 'haven\x92t': 0.84; 'i\x92d': 0.84; 'skip:\x91 10': 0.84; 'can\x92t': 0.91; 'secret.': 0.91; 'to:none': 0.92; 'hot': 0.96 X-CT-Class: Clean X-CT-Score: 0.00 X-CT-RefID: str=0001.0A020208.5311822C.004F,ss=1,re=0.000,fgs=0 X-CT-Spam: 0 X-Authority-Analysis: v=2.0 cv=Q4UMFfKa c=1 sm=1 a=MB85R812cvcrhCHz/P2OVA==:17 a=9cW_t1CCXrUA:10 a=qI3VdyxsKXMA:10 a=G8Uczd0VNMoA:10 a=kviXuzpPAAAA:8 a=SinMJkO-J-70XLLCaG4A:9 a=pILNOxqGKmIA:10 a=NdSEMZCYwYrcr12T:21 a=oqXERSYYK7F78xcJ:21 a=pGC32t_bLFJM4FqAR-gA:9 a=_W_S_7VecoQA:10 a=GPgzPVs2SUgA:10 a=MB85R812cvcrhCHz/P2OVA==:117 X-CM-Score: 0.00 Authentication-Results: cox.net; auth=pass (PLAIN) smtp.auth=swdunning@cox.net From: Scott W Dunning Content-Type: multipart/alternative; boundary="Apple-Mail=_0F82363B-228A-40AD-8EC6-E913C255C9D8" Date: Fri, 28 Feb 2014 23:46:02 -0700 Subject: Help with "Guess the number" script Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\)) X-Mailer: Apple Mail (2.1827) X-Mailman-Approved-At: Sat, 01 Mar 2014 08:24:17 +0100 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: 196 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393658659 news.xs4all.nl 2944 [2001:888:2000:d::a6]:54861 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67302 --Apple-Mail=_0F82363B-228A-40AD-8EC6-E913C255C9D8 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 Hello, i am working on a project for learning python and I=92m stuck. = The directions are confusing me. Please keep in mind I=92m very ne to = this. The directions are long so I=92ll just add the paragraphs I=92m = confused about and my code if someone could help me out I=92d greatly = appreciate it! Also, we haven=92t learned loops yet so just conditional = operators and for some reason we can=92t use global variables. =20 from random import randrange randrange(1, 101) from random import seed seed(129) =20 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""" =20 def get_guess(guess_number): print "(",guess_number,")""Plese enter a guess:" current_guess =3D raw_input() return int(guess_number) def main(): print_description() secret =3D 50 current_guess =3D 1 get_guess(1) if current_guess !=3D secret(): print "Congratulations you win!!" =20 main() Here are the instructions I=92m having a hard time with and just not = sure I=92m doing it correctly. I=92m not sure the get_guess function is = correct and I=92m a little lost with the secret and current_guess = variable. =46rom within the body of the main function, immediately after the call = to print description, create variable secret and assign it a random = number between 1 and 100, generated using the randrange function. You = will need to pass two argument to randrange, what do you think they = should be? You should be able to use the python help system or online = python documentation to make sure you understand the arguments to = randrange. After the end of the body of the print description function, define a = new global function named get guess that takes a single parameter. Name = the parameter guess number, because it will hold the index (1, 2, 3, = ..., 10) of current guess attempt. Make the function ask the user to = enter guess using the raw input function. The function will return the = number entered by the user, after it has been converted to an integer. Return to the main function after the statement that assigned a value to = the secret variable. In a new variable named current guess store the = result of calling the get guess function with an argument of 1. Run your = program to make sure it works correctly. At the end of the main function, check if the current guess matches the = secret. If it matches, print =91Congratulations, you win!=92. If it does = not, print =91Please play again!=92=20 Thanks again!!! --Apple-Mail=_0F82363B-228A-40AD-8EC6-E913C255C9D8 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252 Hello, = i am working on a project for learning python and I=92m stuck.  The = directions are confusing me.  Please keep in mind I=92m very ne to = this.  The directions are long so I=92ll just add the paragraphs = I=92m confused about and my code if someone could help me out I=92d = greatly appreciate it!  Also, we haven=92t learned loops yet so = just conditional operators and for some reason we can=92t use global = variables.  


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

from = random import seed
seed(129)
    
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 =3D raw_input()
    return int(guess_number)

def main():
    print_description()
    secret =3D = 50
    = current_guess =3D 1
    get_guess(1)
    if current_guess !=3D = secret():
  =       print "Congratulations you = win!!"
  =  
main()


Here are = the instructions I=92m having a hard time with and just not sure I=92m = doing it correctly.  I=92m not sure the get_guess function is = correct and I=92m a little lost with the secret and current_guess = variable.

  1. =46rom within the body of = the main function, = immediately after the call to print description, create variable secret and assign it a random number between 1 and = 100, generated using the randrange function. You will need to pass two argument to randrange, what do you think they should be? You = should be able to use the python help system or online python = documentation to make sure you understand the arguments = to randrange.

  2. After the end of the body of = the print description function, define a new global function named get = guess that takes a single = parameter. Name the parameter guess number, because it will hold the index (1, 2, 3, ..., 10) of current = guess attempt. Make the function ask the user to enter guess using = the raw input function. The function will return the number entered by the = user, after it has been converted to an integer.

    Return to the main function after the statement that assigned a = value to the secret variable. = In a new variable named current guess store the result of calling the get = guess function with an = argument of 1. Run your program to make sure it works = correctly.

  1. At the end of the main function, check if the current guess matches = the secret. If it matches, print =91Congratulations, you win!=92. If it = does not, print =91Please play = again!=92 





Thanks again!!!




= --Apple-Mail=_0F82363B-228A-40AD-8EC6-E913C255C9D8--