Re: guessthenumber print games left

2013-04-11 Thread Neil Cerutti
On 2013-04-11, eschneide...@comcast.net
 wrote:
> If you get the time, please post an example, because I don't
> understand.

Maybe it would help to think about contraints. Write them next to
your variable names, and then check, at every point in your
program, if the contraint is still true.

Here's and example.

maximum_games = 4  # You must stop playing after 4 games.
games_played = 0   # Always equals the number of games played
while games_played < maximum_games:
play_game()
# This is where you update games_played to reflect the number
# of games played.
  
-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-11 Thread Chris Angelico
On Thu, Apr 11, 2013 at 5:15 PM,   wrote:
> If you get the time, please post an example, because I don't understand.

(It helps to include some quoted text to provide context to your post.)

Imagine you had a program that just showed the number of games left,
nothing else. Write me out what you would expect that program to
output. Just do it manually so I can see what you're trying to do.

That'll also help you sort out, in your own mind, what you're doing.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-11 Thread eschneider92
If you get the time, please post an example, because I don't understand.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-10 Thread Chris Angelico
On Thu, Apr 11, 2013 at 4:15 PM,   wrote:
> The 2 makes the game play twice instead of 3 times, right? I've tried it with 
> the 1, but but I'm still having trouble. Again, to be exact, I want to 
> somehow make it count down from 2 (the number of games)and print. If that's 
> what this does, is it possible to insert it into my original main program?

Let's leave Python aside for a moment and go back to grade-school arithmetic.

How do you count up to three?
1, 2, 3

How much do you add to a number to get to the next number?

Once you figure out where you're starting, how much you're increasing
at each step, and where you're stopping, you can put those numbers
into your program.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-10 Thread eschneider92
The 2 makes the game play twice instead of 3 times, right? I've tried it with 
the 1, but but I'm still having trouble. Again, to be exact, I want to somehow 
make it count down from 2 (the number of games)and print. If that's what this 
does, is it possible to insert it into my original main program?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-10 Thread Chris Angelico
On Thu, Apr 11, 2013 at 3:56 PM,   wrote:
> How do I make it say that I have one game left? I'm having trouble fitting it 
> into my main code. Thanks a lot for the help btw.

The main confusion seems to be over whether to add one or two. If you
add one, it'll tell you you have just one game left (at some point).
Try that!

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-10 Thread eschneider92
How do I make it say that I have one game left? I'm having trouble fitting it 
into my main code. Thanks a lot for the help btw.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-10 Thread Chris Angelico
On Thu, Apr 11, 2013 at 3:41 PM,   wrote:
> (Didn't mean to post the last bit.) Is this possibly what you meant? If it is 
> I still can't figure out how to apply it to the guessthenumber program.
> numberofgames=1
> while numberofgames<4:
> numberofgames=numberofgames+2
> print (4-numberofgames)
> if numberofguesses>3:
> print(numberofgames)

That's close to it. I still don't understand why you're adding two,
and the last print seems to be unnecessary. But if you just add one,
then yes, that would be exactly what you want.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-10 Thread eschneider92
(Didn't mean to post the last bit.) Is this possibly what you meant? If it is I 
still can't figure out how to apply it to the guessthenumber program. 
numberofgames=1 
while numberofgames<4: 
numberofgames=numberofgames+2
print (4-numberofgames)
if numberofguesses>3:
print(numberofgames)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-10 Thread eschneider92
On Wednesday, April 10, 2013 5:39:23 AM UTC-4, eschne...@comcast.net wrote:
> Could anyone tell me how to make the program tell me how many games are left 
> before the first game and second game? For example, after one game of guess 
> the number, I want it to tell me that i get one more game. P.S. I'm totally 
> new to python (obviously), and I just added numberofgames variable in hopes 
> of solving this problem. am I on the right track? Thanks for any assistance!
> 
> numberofgames=1
> 
> while numberofgames<4:
> 
> numberofgames=numberofgames+2
> 
> import random
> 
> print ('type name')
> 
> name=input()
> 
> print ('guess a number between 1 and 20, ' + name)
> 
> number=random.randint(1,20)
> 
> guessestaken=0
> 
> while guessestaken<5:
> 
> guessestaken=guessestaken+1
> 
> guess=input()
> 
> guess=int(guess)
> 
> if guess 
> print ('your guess is too low')
> 
> if guess>number:
> 
> print ('your guess is too high0')
> 
> if guess==number:
> 
> break
> 
> if guess==number:
> 
> print ('you win!')
> 
> if guess!=number:
> 
> number=str(number)
> 
> print ('you lose. the number was ' + number)

I can't figure out how to make it count down by itself and state how many are 
left.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-10 Thread Chris Angelico
On Thu, Apr 11, 2013 at 7:01 AM,   wrote:
> On Wednesday, April 10, 2013 5:44:20 AM UTC-4, Chris Angelico wrote:
>> On Wed, Apr 10, 2013 at 7:39 PM,   wrote:
>>
>> You have here a counter, but it's counting up. To figure out how many
>> games are left, just subtract the numberofgames from the total number
>> of games that you'll be allowing - that's how many there are left. Do
>> you know how to do that?
>>
>
> Thanks for the quick reply. I've been trying your advice but I can't figure 
> it out. If anyone could show me how to do it in program form, it would be 
> much obliged.

Set your current code aside, and just make a program that counts games
without actually playing them. Start with this part of your existing
code:

numberofgames=1
while numberofgames<4:
numberofgames=numberofgames+2

That will run, but do nothing. Now add a print call to the loop, and
see if you can work out how to make it count how many games are left.

If you get stuck, post the code for just this program and we'll see
where it takes us!

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-10 Thread eschneider92
On Wednesday, April 10, 2013 5:44:20 AM UTC-4, Chris Angelico wrote:
> On Wed, Apr 10, 2013 at 7:39 PM,   wrote:
> 
> > Could anyone tell me how to make the program tell me how many games are 
> > left before the first game and second game? For example, after one game of 
> > guess the number, I want it to tell me that i get one more game. P.S. I'm 
> > totally new to python (obviously), and I just added numberofgames variable 
> > in hopes of solving this problem. am I on the right track? Thanks for any 
> > assistance!
> 
> 
> 
> > numberofgames=1
> 
> > while numberofgames<4:
> 
> > numberofgames=numberofgames+2
> 
> 
> 
> First off, why are you adding two? Is this a typo?
> 
> 
> 
> You have here a counter, but it's counting up. To figure out how many
> 
> games are left, just subtract the numberofgames from the total number
> 
> of games that you'll be allowing - that's how many there are left. Do
> 
> you know how to do that?
> 
> 
> 
> ChrisA

Thanks for the quick reply. I've been trying your advice but I can't figure it 
out. If anyone could show me how to do it in program form, it would be much 
obliged.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-10 Thread Chris Angelico
On Wed, Apr 10, 2013 at 7:39 PM,   wrote:
> Could anyone tell me how to make the program tell me how many games are left 
> before the first game and second game? For example, after one game of guess 
> the number, I want it to tell me that i get one more game. P.S. I'm totally 
> new to python (obviously), and I just added numberofgames variable in hopes 
> of solving this problem. am I on the right track? Thanks for any assistance!

> numberofgames=1
> while numberofgames<4:
> numberofgames=numberofgames+2

First off, why are you adding two? Is this a typo?

You have here a counter, but it's counting up. To figure out how many
games are left, just subtract the numberofgames from the total number
of games that you'll be allowing - that's how many there are left. Do
you know how to do that?

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


guessthenumber print games left

2013-04-10 Thread eschneider92
Could anyone tell me how to make the program tell me how many games are left 
before the first game and second game? For example, after one game of guess the 
number, I want it to tell me that i get one more game. P.S. I'm totally new to 
python (obviously), and I just added numberofgames variable in hopes of solving 
this problem. am I on the right track? Thanks for any assistance!
numberofgames=1
while numberofgames<4:
numberofgames=numberofgames+2
import random
print ('type name')
name=input()
print ('guess a number between 1 and 20, ' + name)
number=random.randint(1,20)
guessestaken=0
while guessestaken<5:
guessestaken=guessestaken+1
guess=input()
guess=int(guess)
if guessnumber:
print ('your guess is too high0')
if guess==number:
break
if guess==number:
print ('you win!')
if guess!=number:
number=str(number)
print ('you lose. the number was ' + number)
-- 
http://mail.python.org/mailman/listinfo/python-list