Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!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.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'argument': 0.05; 'importing': 0.05; 'assignment': 0.07; 'directions': 0.09; 'exist,': 0.09; 'subject:number': 0.09; 'subject:script': 0.09; 'cc:addr:python-list': 0.11; 'subject:Help': 0.11; 'def': 0.12; 'language.': 0.14; 'random': 0.14; 'hint:': 0.16; 'made,': 0.16; 'main():': 0.16; 'said.': 0.16; 'threw': 0.16; 'wrote:': 0.18; 'module': 0.19; 'file,': 0.19; 'received:10.0.1': 0.19; 'programming': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; '': 0.91; 'this;': 0.91; 'mistakes': 0.93; 'hot': 0.96 X-CT-Class: Clean X-CT-Score: 0.00 X-CT-RefID: str=0001.0A020203.53128407.003A,ss=1,re=0.000,fgs=0 X-CT-Spam: 0 X-Authority-Analysis: v=2.0 cv=DLtRFVxb c=1 sm=1 a=MB85R812cvcrhCHz/P2OVA==:17 a=gK21Zm9gRZcA:10 a=G8Uczd0VNMoA:10 a=kviXuzpPAAAA:8 a=QrVWhbZvAAAA:8 a=Yl9YnF-DoBwW1TXVMI0A:9 a=pILNOxqGKmIA:10 a=BpueIgYPnBtMKN-X:21 a=SMKqqMPPfwzhcqBh:21 a=Y9HkQKCSExMAk6Uw13YA:9 a=_W_S_7VecoQA:10 a=Ce03D7dSkpsA: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=_D9D5BDEF-F6E2-4721-8010-CFEEEE41DBEA" 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: Sat, 1 Mar 2014 18:06:09 -0700 References: <43B63C46-3A2D-4374-8A42-EE931BA9A6C4@cox.net> To: Dennis Lee Bieber 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: 246 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393727434 news.xs4all.nl 2876 [2001:888:2000:d::a6]:35735 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67405 --Apple-Mail=_D9D5BDEF-F6E2-4721-8010-CFEEEE41DBEA Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 On Mar 1, 2014, at 9:35 AM, Dennis Lee Bieber = wrote: > Without loops, one part of your assignment is going to be = tedious, > unless the intent is to only allow for one guess per run. No, 10 guesses per game. Yes very tedious and repetative. >=20 >> from random import randrange >> randrange(1, 101) >=20 > You generated a random number and then threw it away. >>=20 >> from random import seed >> seed(129) I do not know what seed is. The directions in the begining said to do = that I guess to test the code through out writing it? This is what the = directions for that part said. At the top of your file, import the randrange function from the random = module. In order to test this module I also want you to import the seed = function from the random module. Immediately after importing it I want = you to call the seed function with an argument of 129. By calling the = seed function we ensure that the sequence of random numbers you generate = will exactly match the ones used in this document.=20 >=20 > Now you are seeding the random number generator but never = generate a > new number after it. >=20 >>=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) >=20 > You're returning the counter of how many guesses have been made, = and > dropping the player's guess into the trash I actually do not understand what you mean here. Should I get rid of = the current_guess line completely? Should it look more like this; def get_guess(guess_number): raw_input(=93Please enter a guess=94) guess_number =3D int(guess_number) return (guess_number) get_guess(1) >=20 >>=20 >> def main(): >> print_description() >> secret =3D 50 >=20 > That's supposed to be the random number, isn't it? Yes it is, I put 50 there because I was going to try and test it. I = think it should be secret =3D randrange(1,101) right? >=20 >> current_guess =3D 1 >> get_guess(1) >=20 > You drop the return value into the trash >=20 >> if current_guess !=3D secret(): >=20 > 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. >=20 >> print "Congratulations you win!!" >=20 >=20 > 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/. Hmm, ok I=92ll try and find what I=92m missing. >=20 > And -- as has been mentioned; these mistakes are better served = in the > tutor list, as they would be mistakes in /any/ common programming = language. > --=20 > =09 Yes, I=92m sorry I completely forgot. I=92ll repost there and go that = route. Thanks though! --Apple-Mail=_D9D5BDEF-F6E2-4721-8010-CFEEEE41DBEA Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252
On Mar 1, 2014, at 9:35 AM, Dennis Lee = Bieber <wlfraed@ix.netcom.com> = wrote:
Without = loops, one part of your assignment is going to be tedious,
unless the = intent is to only allow for one guess per = run.
No, 10 guesses per game.  Yes very = tedious and repetative.

from = random import randrange
randrange(1, 101)

You = generated a random number and then threw it away.

from random import = seed
seed(129)
I do not know what = seed is.  The directions in the begining said to do that I guess to = test the code through out writing it?  This is what the directions = for that part said.
=09 =09 =09
  1. At the top of your file, import the randrange = function from the random module. In order to test this = module I also want you to import the seed function = from the random = module. = Immediately after importing it I want you to call the seed = function with an argument of 129. By calling the seed function = we ensure that the sequence of random numbers you generate will exactly match the ones used in this = document. 


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 = =3D 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
I actually do not understand what you = mean here.  Should I get rid of the current_guess line completely? =  Should it look more like this;

def = get_guess(guess_number):
raw_input(=93Please enter a = guess=94)
= guess_number =3D int(guess_number)
return = (guess_number)
get_guess(1)


def = main():
  print_description()
  secret =3D = 50

That's supposed to be the random = number, isn't it?
Yes it is, I put 50 there = because I was going to try and test it.  I think it should be = secret =3D randrange(1,101) right?

  current_guess =3D = 1
  get_guess(1)

You drop = the return value into the trash

  if current_guess !=3D = 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/.
Hmm, ok I=92ll try and find what = I=92m missing.


= And -- as has been mentioned; these mistakes are better served in = the
tutor list, as they would be mistakes in /any/ common programming = language.
-- 
=
Yes, I=92m sorry I completely forgot. =  I=92ll repost there and go that route.  Thanks = though!


= --Apple-Mail=_D9D5BDEF-F6E2-4721-8010-CFEEEE41DBEA--