Re: [Tutor] Help with Guess the number script

2014-03-12 Thread Danny Yoo
> > Such errors are either obvious or invisible. A remedy is often to figure the > problem on paper (or in your head if you're good at thinking visually). > Here, just draw a line segment with secret in the middle and the interval > borders around. Then, write there on the drawing the _values_ of t

Re: [Tutor] Help with Guess the number script

2014-03-12 Thread Dave Angel
Scott W Dunning Wrote in message: > > On Mar 11, 2014, at 7:50 PM, William Ray Wing wrote: >> >> Simple. In Mail Preferences -> Composing -> Message Format -> Plain Text >> (Your setting is probably currently Rich Text.) >> > Got it, hopefully that helps. Perfect, thanks. -- DaveA ___

Re: [Tutor] Help with Guess the number script

2014-03-12 Thread spir
On 03/12/2014 05:13 AM, Scott Dunning wrote: >> if guess < secret - 10 or guess > secret - 10: > >This is the right idea for cutting the line count but you >have the comparison values wrong. Look back to earlier >emails, you are repeating the same error as before. >Manually think through wha

Re: [Tutor] Help with Guess the number script

2014-03-12 Thread Scott Dunning
On Mar 10, 2014, at 11:18 PM, Dave Angel wrote: > if guess < secret - 10 or guess > secret - 10: > > Think about that line. You might even want to put in a separate > function to test what it does. > HINT: it's wrong. > Got it! I realized what I was doing wrong. I needed that plus sign f

Re: [Tutor] Help with Guess the number script

2014-03-12 Thread Scott Dunning
On Mar 11, 2014, at 1:57 AM, Alan Gauld wrote: > OK so far, you don't need all the print statements > but that's just a style issue. (You could just > insert '\n' characters instead.) You’re right, I’m actually not sure why I did it that way. > >> if guess < secret - 10 or guess > secret -

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread Scott W Dunning
On Mar 11, 2014, at 7:50 PM, William Ray Wing wrote: > > Simple. In Mail Preferences -> Composing -> Message Format -> Plain Text > (Your setting is probably currently Rich Text.) > Got it, hopefully that helps. ___ Tutor maillist - Tutor@python

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread William Ray Wing
On Mar 11, 2014, at 8:06 PM, Scott W Dunning wrote: [mega byte] >> > Yeah, I had no idea that my messages were coming through in HTML, nor what it > looked like until someone sent me a section showing me what it looked like, I > can see how that would be frustrating. > > I’m using the mail

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread Scott W Dunning
On Mar 11, 2014, at 1:49 AM, Alan Gauld wrote: > > Not from the tutor list though. It only has a few > mails normally - less than 50 most days. > Actually now that you say that most of the emails are coming through the reg python-lists, not the tutor section. I guess I should just unsubscribe

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread spir
On 03/11/2014 05:07 AM, Scott W Dunning wrote: On Mar 8, 2014, at 3:57 AM, spir wrote: Well done. And now that you have the right set of tests you can half the number of lines by combining your if conditions again, like you had in the original post. ie. Bring your hot/cold/warm tests together.

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread spir
On 03/11/2014 09:57 AM, Alan Gauld wrote: On 11/03/14 04:07, Scott W Dunning wrote: On Mar 8, 2014, at 3:57 AM, spir mailto:denis.s...@gmail.com>> wrote: And now that you have the right set of tests you can half the number of lines by combining your if conditions again, like you had in the orig

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread spir
On 03/11/2014 04:32 AM, Scott W Dunning wrote: On Mar 8, 2014, at 11:50 AM, Scott dunning wrote: And now that you have the right set of tests you can half the number of lines by combining your if conditions again, like you had in the original post. ie. Bring your hot/cold/warm tests together.

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread Alan Gauld
On 11/03/14 04:07, Scott W Dunning wrote: On Mar 8, 2014, at 3:57 AM, spir mailto:denis.s...@gmail.com>> wrote: And now that you have the right set of tests you can half the number of lines by combining your if conditions again, like you had in the original post. ie. Bring your hot/cold/warm tes

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread Alan Gauld
On 11/03/14 07:42, Scott W Dunning wrote: On Mar 10, 2014, at 11:18 PM, Dave Angel wrote: Where are you guys using the forum? Personally I use the news feed from Gmane.org I read it in Thunderbird (or occasionally via a newsreader on my smartphone/tablet). You can also read it online in a br

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread Scott W Dunning
On Mar 10, 2014, at 11:18 PM, Dave Angel wrote: Where are you guys using the forum? Through google? I was using that at first but someone complained about something that google does and told me to get it through my email. That’s what I’m doing now and I get bombarded with about 500 emails

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread Scott W Dunning
On Mar 10, 2014, at 11:18 PM, Dave Angel wrote: > Scott W Dunning Wrote in message: >> > > Would you please stop posting in html? I don’t know what you mean? I just use the text for my email provider. It’s not html? I types up the code I had in the script.

Re: [Tutor] Help with Guess the number script

2014-03-10 Thread Dave Angel
Scott W Dunning Wrote in message: > Would you please stop posting in html? > def print_hints(secret, guess):     if guess < 1 or guess > 100:         print         print "Out of range!"         print     if guess < secret:         print         print "Too low!"     i

Re: [Tutor] Help with Guess the number script

2014-03-10 Thread Scott W Dunning
On Mar 8, 2014, at 11:50 AM, Scott dunning wrote: >>> >>> And now that you have the right set of tests you can >>> half the number of lines by combining your if >>> conditions again, like you had in the original >>> post. ie. Bring your hot/cold/warm tests together. I’m having a hard time doing

Re: [Tutor] Help with Guess the number script

2014-03-10 Thread Scott W Dunning
>> On Mar 8, 2014, at 3:57 AM, spir wrote: >>> >>> Well done. >>> And now that you have the right set of tests you can >>> half the number of lines by combining your if >>> conditions again, like you had in the original >>> post. ie. Bring your hot/cold/warm tests together. So below is what I fi

Re: [Tutor] Help with Guess the number script

2014-03-10 Thread Scott W Dunning
On Mar 10, 2014, at 4:15 AM, eryksun wrote: > > Different strokes for different folks. I like to tinker with and > disassemble things as I'm learning about them. I would have been > ecstatic about open source as a kid. I learn simultaneously from the > top down and bottom up -- outside to inside

Re: [Tutor] Help with Guess the number script

2014-03-10 Thread eryksun
On Mon, Mar 10, 2014 at 5:29 AM, Mark Lawrence wrote: > > As a newbie don't worry about it (yet). Personally I think it's plain daft > to put such advanced language topics on a tutor mailing list. Different strokes for different folks. I like to tinker with and disassemble things as I'm learning

Re: [Tutor] Help with Guess the number script

2014-03-10 Thread Mark Lawrence
On 10/03/2014 02:03, Scott W Dunning wrote: On Mar 8, 2014, at 7:29 AM, eryksun wrote: Anyway, you needn't go out of your way to rewrite the expression using a chained comparison. The disjunctive expression is actually implemented more efficiently by CPython's compiler, which you can verify us

Re: [Tutor] Help with Guess the number script

2014-03-10 Thread Mark Lawrence
On 10/03/2014 02:05, Scott W Dunning wrote: On Mar 8, 2014, at 7:35 AM, Mark Lawrence wrote: I have no interest in the efficiency, only what is easiest for me to read, which in this case is the chained comparison. As a rule of thumb I'd also prefer it to be logically correct :) What exac

Re: [Tutor] Help with Guess the number script

2014-03-10 Thread Scott W Dunning
On Mar 8, 2014, at 7:35 AM, Mark Lawrence wrote: > > I have no interest in the efficiency, only what is easiest for me to read, > which in this case is the chained comparison. As a rule of thumb I'd also > prefer it to be logically correct :) > What exactly is ment by a chained comparison?

Re: [Tutor] Help with Guess the number script

2014-03-10 Thread Scott W Dunning
On Mar 8, 2014, at 7:29 AM, eryksun wrote: > i.e. > >guess < 1 or guess > 100 > > becomes > >not not (guess < 1 or guess > 100) Why a not not? Wouldn’t that just be saying do this because the second not is undoing the first? > > distribute over the disjunction > >not (not (gue

Re: [Tutor] Help with Guess the number script

2014-03-09 Thread eryksun
> On Mar 8, 2014, at 7:29 AM, eryksun wrote: >> >>not not (guess < 1 or guess > 100) > > Why a not not? Wouldn’t that just be saying do this because the > second not is undoing the first? In boolean algebra, `not (A or B)` is equivalent to `not A and not B` (De Morgan's law). I double negate

Re: [Tutor] Help with Guess the number script

2014-03-08 Thread eryksun
On Sat, Mar 8, 2014 at 1:44 PM, Scott dunning wrote: >> if 1 > guess > 100: >> > OH! I see what you're saying, ignore my last post. Yes that looks > cleaner. Please read section 6.9 of the language reference, which defines Python comparison expressions. http://docs.python.org/3/reference/expre

Re: [Tutor] Help with Guess the number script

2014-03-08 Thread Scott dunning
> On Mar 8, 2014, at 3:57 AM, spir wrote: > >> On 03/08/2014 10:13 AM, Alan Gauld wrote: >>> On 08/03/14 01:23, Scott W Dunning wrote: >>> >>> On Mar 7, 2014, at 11:02 AM, Alan Gauld wrote: >>> >>> GOT IT!! Finally! Thanks for all of your help!! >>> >>> This is what I got, not sure if it’s

Re: [Tutor] Help with Guess the number script

2014-03-08 Thread Scott dunning
> On Mar 8, 2014, at 6:26 AM, Mark Lawrence wrote: > >> On 08/03/2014 01:23, Scott W Dunning wrote: >> >> On Mar 7, 2014, at 11:02 AM, Alan Gauld wrote: >> >> GOT IT!! Finally! Thanks for all of your help!! > > If at first you don't succeed... :) > >> >> This is what I got, not sure if i

Re: [Tutor] Help with Guess the number script

2014-03-08 Thread Scott dunning
> On Mar 8, 2014, at 6:36 AM, Dave Angel wrote: > > Mark Lawrence Wrote in message: >>> On 08/03/2014 01:23, Scott W Dunning wrote: >>> >>> >>> def print_hints(secret, guess): >>> if guess < 1 or guess > 100: >> >> Only now do I feel that it's time to point out that the above line would

Re: [Tutor] Help with Guess the number script

2014-03-08 Thread Mark Lawrence
On 08/03/2014 14:29, eryksun wrote: Anyway, you needn't go out of your way to rewrite the expression using a chained comparison. The disjunctive expression is actually implemented more efficiently by CPython's compiler, which you can verify using the dis module to disassemble the bytecode. I h

Re: [Tutor] Help with Guess the number script

2014-03-08 Thread eryksun
On Sat, Mar 8, 2014 at 8:36 AM, Dave Angel wrote: > Mark Lawrence Wrote in message: >> On 08/03/2014 01:23, Scott W Dunning wrote: >> >>> def print_hints(secret, guess): >>> if guess < 1 or guess > 100: >> >> Only now do I feel that it's time to point out that the above line would >> probab

Re: [Tutor] Help with Guess the number script

2014-03-08 Thread Dave Angel
Mark Lawrence Wrote in message: > On 08/03/2014 01:23, Scott W Dunning wrote: > >> >> def print_hints(secret, guess): >> if guess < 1 or guess > 100: > > Only now do I feel that it's time to point out that the above line would > probably be written by an experienced Python programmer as:-

Re: [Tutor] Help with Guess the number script

2014-03-08 Thread Mark Lawrence
On 08/03/2014 01:23, Scott W Dunning wrote: On Mar 7, 2014, at 11:02 AM, Alan Gauld wrote: GOT IT!! Finally! Thanks for all of your help!! If at first you don't succeed... :) This is what I got, not sure if it’s correct but it’s working! def print_hints(secret, guess): if guess <

Re: [Tutor] Help with Guess the number script

2014-03-08 Thread spir
On 03/08/2014 10:13 AM, Alan Gauld wrote: On 08/03/14 01:23, Scott W Dunning wrote: On Mar 7, 2014, at 11:02 AM, Alan Gauld wrote: GOT IT!! Finally! Thanks for all of your help!! This is what I got, not sure if it’s correct but it’s working! Well done. And now that you have the right set

Re: [Tutor] Help with Guess the number script

2014-03-08 Thread Alan Gauld
On 08/03/14 01:23, Scott W Dunning wrote: On Mar 7, 2014, at 11:02 AM, Alan Gauld wrote: GOT IT!! Finally! Thanks for all of your help!! This is what I got, not sure if it’s correct but it’s working! Well done. And now that you have the right set of tests you can half the number of lines

Re: [Tutor] Help with Guess the number script

2014-03-08 Thread Scott W Dunning
On Mar 7, 2014, at 11:02 AM, Alan Gauld wrote: GOT IT!! Finally! Thanks for all of your help!! This is what I got, not sure if it’s correct but it’s working! def print_hints(secret, guess): if guess < 1 or guess > 100: print print "Out of range!" print if gues

Re: [Tutor] Help with Guess the number script

2014-03-07 Thread Alan Gauld
On 07/03/14 05:30, Scott W Dunning wrote: I am trying to write a script for class for a game called guess the number. Others have given general hints here are a couple of specifics... def print_hints(secret, guess): if guess < 1 or guess > 101: As I recall the spec said guesses could b

Re: [Tutor] Help with Guess the number script

2014-03-07 Thread spir
On 03/07/2014 06:30 AM, Scott W Dunning wrote: I am trying to write a script for class for a game called guess the number. I’m almost done but, I’m having a hard time getting the hints to print correctly. I’ve tried ‘if’’ ‘elif’ nested, it seems like everything….I’m posting my code for the h

Re: [Tutor] Help with Guess the number script

2014-03-07 Thread Peter Otten
Scott W Dunning wrote: > I am trying to write a script for class for a game called guess the > number. I’m almost done but, I’m having a hard time getting the hints to > print correctly. I’ve tried ‘if’’ ‘elif’ nested, it seems like > everything….I’m posting my code for the hints below, any help

Re: [Tutor] Help with Guess the number script

2014-03-07 Thread Danny Yoo
One more note: I used round parenthesis in the diagrams above to indicate intervals. If you think about it a bit, you'll realize I should be using square brackets in some places, or make some distinctive graphic. Open and closed circles, perhaps? Otherwise, there are tiny pinpoint gaps in the c

Re: [Tutor] Help with Guess the number script

2014-03-07 Thread Ben Finney
Scott W Dunning writes: > I am trying to write a script for class for a game called guess the > number. I’m almost done but, I’m having a hard time getting the hints > to print correctly. I’ve tried ‘if’’ ‘elif’ nested, it seems like > everything…. And, what happens? Please describe what you d

Re: [Tutor] Help with Guess the number script

2014-03-07 Thread Danny Yoo
Can you split the conditions so that they're not overlapping? One of the things that you learn about programming is that if the program is hard for humans to read, even if the program is computing something useful, you may want to work to make it humanly understandable, even if the human is having

[Tutor] Help with Guess the number script

2014-03-07 Thread Scott W Dunning
I am trying to write a script for class for a game called guess the number. I’m almost done but, I’m having a hard time getting the hints to print correctly. I’ve tried ‘if’’ ‘elif’ nested, it seems like everything….I’m posting my code for the hints below, any help is greatly appreciated! d

Re: [Tutor] Help with "Guess the number" script

2014-03-04 Thread Alan Gauld
On 04/03/14 02:29, Scott W Dunning wrote: I’ve made some changes and have a couple questions, I’ll speak in between the code. from random import randrange randrange(1, 101) This call to randrange() doesn't do anything because you don't store the return value. You need to create a variable t

Re: [Tutor] Help with "Guess the number" script

2014-03-04 Thread Danny Yoo
> If not, then you might even try something like: > > # > def maybe_print_cold(): > if guess < (secret - 10) or guess > (secret - 10): > print "You are cold!" > print > print "Please play again!” > # ... Ooops. You proba

Re: [Tutor] Help with "Guess the number" script

2014-03-04 Thread Danny Yoo
Once a function gets beyond about six or seven lines long, it's a bit hard to read, and harder to get the indentation right. You're having difficulty with the indentation, but that's often a sign that the function is too big to read comfortably. Can you break the function down into a few pieces?

Re: [Tutor] Help with "Guess the number" script

2014-03-04 Thread Scott W Dunning
On Mar 3, 2014, at 3:29 AM, spir wrote: I have another question in regard to this guess the number script I’m working on. I’m banging my head over why this isn’t working…. def print_hints(secret, guess): if guess < 1 or guess > 101: print print "Out of range!" prin

Re: [Tutor] Help with "Guess the number" script

2014-03-04 Thread Scott W Dunning
On Mar 3, 2014, at 3:27 AM, spir wrote: > > There are 2 user guesses here, and only 1 variable, thus 1 name. The name > should say what (idea) the variable represents in the program; this should be > said by the name's *meaning*. It is one of the greatest difficulties in > programming. How wo

Re: [Tutor] Help with "Guess the number" script

2014-03-04 Thread Scott W Dunning
On Mar 3, 2014, at 1:51 AM, Ben Finney wrote: > "Bold” assumes that markup of text will survive; that's not reliable, > since this is a text-only medium and only the plain text will reliably > survive to all readers. Sorry, I didn’t realize. I’m still new to this. > > You're creating a prompt s

Re: [Tutor] Help with "Guess the number" script

2014-03-03 Thread spir
On 03/03/2014 11:27 AM, spir wrote: How would you define what these variables represent, using everyday language? My own definitions would lead me to choose the following variable names: guess_text = raw_input(promt) guess_number = int(user_guess) return guess_number sorry,

Re: [Tutor] Help with "Guess the number" script

2014-03-03 Thread spir
On 03/03/2014 05:03 AM, Scott W Dunning wrote: Ben Finney makes numerous fine comments already. I'll add a few, some on the same points but but expressed a bit differently (case it helps). This is what Im having trouble with now. Here are the directions I’m stuck on and what I have so far,

Re: [Tutor] Help with "Guess the number" script

2014-03-03 Thread Ben Finney
Scott W Dunning writes: > This is what Im having trouble with now. Here are the directions I’m > stuck on and what I have so far, I’ll bold the part that’s dealing > with the instructions if anyone could help me figure out where I’m > going wrong. “Bold” assumes that markup of text will survive;

Re: [Tutor] Help with "Guess the number" script

2014-03-03 Thread Scott W Dunning
This is what Im having trouble with now. Here are the directions I’m stuck on and what I have so far, I’ll bold the part that’s dealing with the instructions if anyone could help me figure out where I’m going wrong. Thanks! from random import randrange randrange(1, 101) from random import s

Re: [Tutor] Help with "Guess the number" script

2014-03-03 Thread Scott W Dunning
On Mar 2, 2014, at 12:43 AM, Ben Finney wrote: > > No, that's the opposite direction :-) Inside the ‘get_guess’ function > you should use as many names as you need for the different purposes. > > So, you have one name ‘guess_number’ bound to the function's parameter. > Don't bind anything else

Re: [Tutor] Help with "Guess the number" script

2014-03-02 Thread Dave Angel
Scott W Dunning Wrote in message: > > On Mar 1, 2014, at 12:47 AM, Ben Finney wrote: > >> You've bound the name ‘current_guess’ to the user's input, but then do >> nothing with it for the rest of the function; it will be discarded >> without being used. > Hmm, I’m not quite sure I unders

Re: [Tutor] Help with "Guess the number" script

2014-03-01 Thread Ben Finney
Ben Finney writes: > So, you have one name ‘guess_number’ bound to the function's parameter. > Don't bind anything else to it! By which I mean, don't bind that name to anything else in the function (don't re-assign any other value to that name in the function). Keep that name's meaning by leavin

Re: [Tutor] Help with "Guess the number" script

2014-03-01 Thread Ben Finney
Scott W Dunning writes: > On Mar 1, 2014, at 12:47 AM, Ben Finney wrote: > > > You've bound the name ‘current_guess’ to the user's input, but then do > > nothing with it for the rest of the function; it will be discarded > > without being used. > Hmm, I’m not quite sure I understand. I got som

Re: [Tutor] Help with "Guess the number" script

2014-03-01 Thread Scott W Dunning
On Mar 1, 2014, at 6:53 AM, spir wrote: > > I find directions very confusing. Also, they completely control you while > explaining about nothing, like a user manual saying "press this, turn that". > This is inappropriate for programming (and anything else): you need to > understand! You need

Re: [Tutor] Help with "Guess the Number" script

2014-03-01 Thread Scott W Dunning
On Mar 1, 2014, at 8:57 AM, Mark Lawrence wrote: > On 01/03/2014 06:05, Scott Dunning wrote: > > In addition to the answers you've already had, I suggest that you learn to > run code at the interactive prompt, it's a great way of seeing precisely what > snippets of code actually do. Also use

Re: [Tutor] Help with "Guess the number" script

2014-03-01 Thread Scott W Dunning
On Mar 1, 2014, at 12:47 AM, Ben Finney wrote: > You've bound the name ‘current_guess’ to the user's input, but then do > nothing with it for the rest of the function; it will be discarded > without being used. Hmm, I’m not quite sure I understand. I got somewhat confused because the direction

Re: [Tutor] Help with "Guess the number" script

2014-03-01 Thread Alan Gauld
On 01/03/14 17:16, Alan Gauld wrote: Scott W Dunning writes: def get_guess(guess_number): print "(",guess_number,")""Plese enter a guess:" Aren't you missing a comma before the last string? I just realized it will work because Python auto joins adjacent string literals. But in this c

Re: [Tutor] Help with "Guess the number" script

2014-03-01 Thread Alan Gauld
Scott W Dunning writes: def get_guess(guess_number): print "(",guess_number,")""Plese enter a guess:" Aren't you missing a comma before the last string? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos

Re: [Tutor] Help with "Guess the Number" script

2014-03-01 Thread Mark Lawrence
On 01/03/2014 06:05, Scott Dunning wrote: In addition to the answers you've already had, I suggest that you learn to run code at the interactive prompt, it's a great way of seeing precisely what snippets of code actually do. Also use the print statement in Python 2 or print function in Python

Re: [Tutor] Help with "Guess the number" script

2014-03-01 Thread spir
On 03/01/2014 07:46 AM, Scott W Dunning wrote: 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 coul

Re: [Tutor] Help with "Guess the number" script

2014-03-01 Thread Dave Angel
Scott W Dunning Wrote in message: In addition to Ben's observation, you don't use anything random when initializing secret. And you don't store the result of get_guess. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change s

Re: [Tutor] Help with "Guess the number" script

2014-02-28 Thread Ben Finney
Scott W Dunning writes: > def get_guess(guess_number): > print "(",guess_number,")""Plese enter a guess:" > current_guess = raw_input() > return int(guess_number) You've bound the name ‘current_guess’ to the user's input, but then do nothing with it for the rest of the function; it w

[Tutor] Help with "Guess the Number" script

2014-02-28 Thread Scott Dunning
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 new 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,

[Tutor] Help with "Guess the number" script

2014-02-28 Thread Scott W Dunning
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, w