Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'argument': 0.05; '(b)': 0.07; 'assignment': 0.07; '"("': 0.09; 'bold': 0.09; 'directions': 0.09; 'function,': 0.09; 'main()': 0.09; 'parameter': 0.09; 'subject:number': 0.09; 'subject:script': 0.09; 'cc:addr:python-list': 0.11; 'subject:Help': 0.11; 'def': 0.12; 'wrote': 0.14; 'random': 0.14; 'conditional': 0.16; 'guess.': 0.16; 'main():': 0.16; 'range,': 0.16; 'wrote:': 0.18; '<': 0.19; 'received:10.0.1': 0.19; 'things.': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; '(a)': 0.24; 'cc:2**0': 0.24; 'define': 0.26; 'task': 0.26; 'second': 0.26; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'statement': 0.30; 'code': 0.31; '"please': 0.31; 'anyone': 0.31; 'figure': 0.32; 'supposed': 0.32; 'thanks!': 0.32; 'option': 0.32; 'guess': 0.33; 'trouble': 0.34; '"the': 0.34; 'subject:the': 0.34; 'could': 0.34; 'subject:with': 0.35; 'add': 0.35; 'received:10.0': 0.36; 'two': 0.37; 'received:10': 0.37; 'checks': 0.38; 'pm,': 0.38; 'does': 0.39; 'subject:" ': 0.39; 'skip:p 20': 0.39; 'skip:u 10': 0.60; 'tell': 0.60; 'new': 0.61; 'numbers': 0.61; 'range': 0.61; 'first': 0.61; 'header:Message-Id:1': 0.63; 'high': 0.63; 'kept': 0.65; 'to:addr:gmail.com': 0.65; 'charset:windows-1252': 0.65; 'within': 0.65; 'here': 0.66; 'mar': 0.68; 'hints': 0.68; 'secret': 0.74; '2014,': 0.84; 'secret.': 0.91; 'scott': 0.93; 'hot': 0.96 X-CT-Class: Clean X-CT-Score: 0.00 X-CT-RefID: str=0001.0A020204.5313FAB0.00C8,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=gK21Zm9gRZcA:10 a=G8Uczd0VNMoA:10 a=kviXuzpPAAAA:8 a=OG9Dvookndn_xi7P1l4A:9 a=pILNOxqGKmIA:10 a=4vB-4DCPJfMA:10 a=D4igxPIFR6kvQVaN:21 a=HvFza3YNJoLXut5w:21 a=Gb1Cj3n4xmhFCtSt46QA:9 a=_W_S_7VecoQA:10 a=MB85R812cvcrhCHz/P2OVA==:117 X-CM-Score: 0.00 Authentication-Results: cox.net; auth=pass (PLAIN) smtp.auth=swdunning@cox.net Content-Type: multipart/alternative; boundary="Apple-Mail=_1E30E07F-8F32-4BC3-A409-B3A00EA0E553" Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\)) Subject: Re: Help with "Guess the number" script From: Scott W Dunning In-Reply-To: Date: Sun, 2 Mar 2014 20:44:47 -0700 References: <43B63C46-3A2D-4374-8A42-EE931BA9A6C4@cox.net> To: Chris Angelico X-Mailer: Apple Mail (2.1827) Cc: "python-list@python.org" 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: 224 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393818297 news.xs4all.nl 2869 [2001:888:2000:d::a6]:40533 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67505 --Apple-Mail=_1E30E07F-8F32-4BC3-A409-B3A00EA0E553 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 On Mar 2, 2014, at 6:40 PM, Scott W Dunning wrote: This is what Im having trouble with now. Here are the directions I=92m = stuck on and what I have so far, I=92ll bold the part that=92s dealing = with the instructions if anyone could help me figure out where I=92m = going wrong. =20 Thanks! 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): promt =3D "(" + str(guess_number) +") Please enter a guess:" user_guess =3D raw_input(promt) user_guess =3D int(user_guess) return user_guess def print_hints(secrets, guess): secret_number =3D secret guess =3D guess if guess < 0 or user_guess> 101: print "Out of range!" def main(): print_description() secret =3D randrange(1,101) current_guess =3D get_guess(1) if current_guess !=3D secret: print_hints(secret_number, guess) current_guess =3D get_guess(2) =20 if secret =3D=3D current_guess: print "Congratulations, you win!" else: print "Please play again" print "The secret number was", secret =20 =20 main() Just below the body of the get guess function, define a new function = named print hints that takes two arguments. The first is a secret num- = ber and is kept in a parameter named secret. The second is a guess made = by the user and it is held in a parameter named guess. The user=92s guess is supposed to be within the range 1 ... 100. Write a = conditional statement that checks if the guess is out of that range, and = if it is print =91out of range=92 in the body of the print hints = function. Now we are going to give the user the option to make a second guess. You = must add code to the main function immediately after assignment = statement you wrote for task 7. Write a conditional statement to check if the current guess does not = match the secret number. If the numbers to not match, in the body of the = conditional statement you will do two things. (a) call print hints to give the user hints, (b) re-assign current guess to the result of calling get guess with an argument of 2.=20= --Apple-Mail=_1E30E07F-8F32-4BC3-A409-B3A00EA0E553 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252
On Mar 2, 2014, at 6:40 PM, Scott W = Dunning <swdunning@cox.net>= wrote:

This is what Im having trouble with now. =  Here are the directions I=92m stuck on and what I have so far, = I=92ll bold the part that=92s dealing with the instructions if anyone = could help me figure out where I=92m going wrong. =  

Thanks!

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):
    promt =3D "(" + str(guess_number) +") Please = enter a guess:"
  =   user_guess =3D raw_input(promt)
    user_guess =3D = int(user_guess)
  =   return user_guess

def print_hints(secrets, guess):
    secret_number =3D = secret
    guess =3D = guess
    if guess = < 0 or user_guess> 101:
        print "Out of = range!"

def = main():
    = print_description()
    secret =3D = randrange(1,101)
  =   current_guess =3D get_guess(1)
    if current_guess !=3D = secret:
    =     print_hints(secret_number, guess)
        current_guess =3D = get_guess(2)
  =       
    if secret =3D=3D = current_guess:
  =       print "Congratulations, you = win!"
    = else:
    =     print "Please play again"
    print "The secret number was", = secret        
          =   
main()
      1. Just below the body of the get guess function, define a new function named print hints that takes = two arguments. The first is a secret num- ber and is kept in a parameter named secret. The second is a guess made by the user and it is held in a parameter named guess.

      2. The user=92s guess is = supposed to be within the range 1 ... 100. Write a conditional statement that checks if the guess is out of that range, and = if it is print =91out of range=92 in the body of the print hints = function.

      3. Now we are going to give the = user the option to make a second guess. You must add code to the main function immediately after assignment statement you wrote for task 7.

        Write a conditional = statement to check if the current guess does not match the secret number. If the numbers to not match, in the body of the conditional statement you will do two things.

          =
        1. (a)  call print hints = to give the user hints,

        2. =
        3. (b)  re-assign current guess = to the result of calling = get = guess with an

          argument of = 2. 

= --Apple-Mail=_1E30E07F-8F32-4BC3-A409-B3A00EA0E553--