Need help improving number guessing game
febaen at gmail.com
Mon Dec 15 10:06:51 CET 2008
>Seems ok. You may want to use arguments with default values for a and b
>(and possibly to use more meaningfull names):
I changed it to minr and maxr. Mini is fine, but I can't name a
variable maxi unless I have a good feminine hygiene joke to use with
I don't see the aim of your changes to setup(). I can kinda understand
checking to make sure that you didn't make the minimum higher than the
maximum, but I think where you put minr/maxr would make it use the
same minr/maxr as the end of the previous game, wouldn't it?
>Minor point for a short program, but still good practice : use
>constants. IE :
I had done this initially, but it seemed wasteful and needlessly
confusing in this situation.
>I assume 'p1sc' means "player_1_score" ?
>If so, you may want to use a dict for scores:
I don't really understand dicts yet; actually, the tutorial I'm
kids/ , designed for tweens, but other than the pointless anecdote and
joke here and there, I've found it a very good guide) doesn't even
seem to mention them, from a search of the pdf. Actually, apparently I
stopped and started working on this just before the chapter on
functions and modules.
I'll look into that later on, but for now I'm pretty happy with how it
><ot>Is it really necessary to WRITE THIS IN ALL UPPERS ?-)</ot>
If you didn't notice, in the original it was "CONGLATURATIONS".
I could also make a "VIDEO GAME BAND. Heavy Metal's Not Dead." joke
here, but I'm afraid a disappointingly small amount of people will get
>Python has proper booleans too
Yeah, I had those initially too, but "play = True" was causing trouble
for some reason when I copy/pasted it into IDLE to try to
troubleshoot, so I changed it to 1. I'll probably change it back
>You should either put this in it's own function (could be named 'main'),
>or at least "protect" it with an "if __name__ == '__main__':" test.
Could you go into a bit more detail on this? I don't understand what
should be its own function, nor do I understand what that line would
do or how to use it.
James, could you work that into a section of what I have to make it a
bit easier to understand?
More information about the Python-list