Re: [Tutor] guess my number game (reversed)

2018-10-06 Thread Peter Otten
chiara pascucci wrote: > Hi, > > sorry for "resurrecting" this thread. I have tried doing as suggested but > with no luck. > I now managed to make the programme work "partially". It works as desired > for "too high" and "right" answer input, but when the users input "too > low" the programme

Re: [Tutor] guess my number game (reversed)

2018-10-06 Thread chiara pascucci
Hi, sorry for "resurrecting" this thread. I have tried doing as suggested but with no luck. I now managed to make the programme work "partially". It works as desired for "too high" and "right" answer input, but when the users input "too low" the programme closes. here is what the code looks like

Re: [Tutor] guess my number game (reversed)

2018-06-01 Thread Farooq Karimi Zadeh
Add a new variable named "number of guesses", increase it each time and break the loop when it reaches, for example 10. This means user can have 10 guesses max. If they couldn't guess the number, they are losers! You also could do the opposite: have number of guesses=10 in the beginning and

Re: [Tutor] guess my number game (reversed)

2018-06-01 Thread Alan Gauld via Tutor
On 01/06/18 14:00, chiara pascucci wrote: > the user's input. The programme works fine if the it guesses the number > right on its first try, but when the users inputs "too low" or "too high" > an infinite loop is returned. I thinkI have done something wrong in my > while loop and that my sentry

[Tutor] guess my number game (reversed)

2018-06-01 Thread chiara pascucci
Hello. I am very new to learning Python, and I would need some help with a little game I am trying to write. I am trying to write a game where the user is asked to think of a number from 1 to a 100, and the computer tries to guess it. Now, after every guess I would want the programme to ask

Re: [Tutor] guess my number game

2018-05-09 Thread Kerri Murphy
Perhaps the indentation was changed when I copy and pasted it, but also we've only been using codeskulptor to run our answers. That code did work on ours, so that is weird. But yes there are a lot of errors. We just type it into code skulptor and press play. A box pops up for any user input.

Re: [Tutor] guess my number game

2018-05-09 Thread Kerri Murphy
Hi there, Yes, the first code does a good job by asking them to go higher or lower after each guess, in the pop up window. The 2nd code works, but only outputs all the higher and lower outputs after the 10 guesses. Everyone in the class has the same result basically. When I searched on various

Re: [Tutor] guess my number game

2018-05-09 Thread Alan Gauld via Tutor
On 9 May 2018 2:30 am, Kerri Murphy wrote: Hi there, Yes, the first code does a good job by asking them to go higher or lower after each guess, in the pop up window. My point is that the code you posted can't even run, let alone do a good job.

Re: [Tutor] guess my number game

2018-05-08 Thread Alan Gauld via Tutor
The first block of code is full of errors and couldn't work so I have no idea what you were really doing! The second block should kind of work. From your description I'd guess you have an indentation error such that most of the code that should be inside the loop is being bypassed. Are you

Re: [Tutor] guess my number game

2018-05-08 Thread Mats Wichmann
On 05/08/2018 06:04 AM, Jan Erik Moström wrote: > >> Here is the code with the while loop >> import random >> n = (random.randint(0,100)) >> g = int(input('Guess my number, 0 to 100, you have 10 chances')) you should get your students into good programming habits right away. Here you are taking

Re: [Tutor] guess my number game

2018-05-08 Thread Jan Erik Moström
Here is the code with the while loop import random n = (random.randint(0,100)) g = int(input('Guess my number, 0 to 100, you have 10 chances')) c = 0 while (c < 10): g = int(input('Guess my number, 0 to 100, you have 10 chances')) c = c + 1 if (g >= n): print('Lower!')

[Tutor] guess my number game

2018-05-08 Thread Kerri Murphy
My students are creating a guess my number game. They are trying to take this type of code (the flow of it), and turn it into a code using a while loop. Here is the first code n = int(input('Guess my number: '))if (n <= 172 and n >= 174): print('Correct')elif (n >= 174): a =

[Tutor] Guess my number game

2013-12-07 Thread Lelani Slabber
Hi,   I am learning Python witht Python for beginners book by Michael Lawson and have trouble with one task in chapter 3 - challenge 3.   I have to add code so the user has a limited number of tries - in this case I have set it to less than 5 in the while loop and I want the program to stop if

Re: [Tutor] Guess my number game

2013-12-07 Thread Mark Lawrence
On 06/12/2013 23:34, Lelani Slabber wrote: Hi, I am learning Python witht Python for beginners book by Michael Lawson and have trouble with one task in chapter 3 - challenge 3. I have to add code so the user has a limited number of tries - in this case I have set it to less than 5 in the while

Re: [Tutor] Guess my number game

2013-12-07 Thread Joel Goldstick
On Sat, Dec 7, 2013 at 9:16 AM, Mark Lawrence breamore...@yahoo.co.ukwrote: On 06/12/2013 23:34, Lelani Slabber wrote: Hi, I am learning Python witht Python for beginners book by Michael Lawson and have trouble with one task in chapter 3 - challenge 3. I have to add code so the user has a

Re: [Tutor] Guess my number game

2013-12-07 Thread Steven D'Aprano
On Fri, Dec 06, 2013 at 11:34:13PM +, Lelani Slabber wrote: I have to add code so the user has a limited number of tries - in this case I have set it to less than 5 in the while loop and I want the program to stop if the tries are equal to 5.  I get an invalid syntax error.  Please

[Tutor] Guess my number game

2011-11-20 Thread myles broomes
I asked for advice yesterday with some pseudocode for a 'guess my number' game I wrote up, and I was told to have a go at writing up the actual code. I've had a go but im struggling... #guess my number games #the user thinks of a number between 1 and 100, #the computer then has to try and guess

Re: [Tutor] Guess my number game

2011-11-20 Thread Alan Gauld
On 20/11/11 15:29, myles broomes wrote: ...I was told to have a go at writing up the actual code. Well done, thats a good start. #guess my number games #the user thinks of a number between 1 and 100, #the computer then has to try and guess that number #welcome the player to the game and

[Tutor] Guess my number game

2011-11-19 Thread myles broomes
I am currently learning Python from the 'Python Programming for the Absolute Beginner' book. At the end of each chapter, you are given challenges and one of the challenges is to make a 'Guess My Number' game where the player thinks of a number between 1 and 100 and the computer has to guess the

Re: [Tutor] Guess my number game

2011-11-19 Thread delegbede
MTN -Original Message- From: myles broomes mylesbroo...@hotmail.co.uk Sender: tutor-bounces+delegbede=dudupay@python.org Date: Sat, 19 Nov 2011 12:53:40 To: tutor@python.org Subject: [Tutor] Guess my number game I am currently learning Python from the 'Python Programming

Re: [Tutor] Guess my number game

2011-11-19 Thread bob gailer
On 11/19/2011 8:14 AM, delegb...@dudupay.com wrote: Hi Myles, Pseudocodes are what anyone would write but they only lay an idea of what you intend to achieve. To get quick help, you need to write the actual code and tell us where the trouble spot is. This way we can help you get along.

Re: [Tutor] Guess my number game

2011-11-19 Thread Alan Gauld
On 19/11/11 12:53, myles broomes wrote: ...Here is the pseudocode I have written up: Once the user has thought of their number, take a guess While the number has not been guessed correctly Increase the number of 'tries' by 1 Ask the user if the guess was too high or too low

Re: [Tutor] guess my number game

2007-03-27 Thread Alexander Kapshuk
I'm working on a program that has the user think of a number between 1 and 100 and then tries to guess that number. I'm having trouble telling the computer to keep on looking for the correct number, each time narrowing down the search range. Please see the code below. import random

Re: [Tutor] guess my number game

2007-03-27 Thread Dick Moores
At 03:16 AM 3/27/2007, Alexander Kapshuk wrote: I’m working on a program that has the user think of a number between 1 and 100 and then tries to guess that number. I’m having trouble telling the computer to keep on looking for the correct number, each time narrowing down the search range.

[Tutor] Guess my number game

2005-12-15 Thread William Mhlanga
I have been trying to write a guess my number game (using Michael Dawsons book), where the computer guesses the number that I thought of. Here is my code so far,#The Guess My Number Game ##The computer picks a random number between 1 and 50#The player tries to guess it and the computer lets#the

Re: [Tutor] Guess my number game

2005-12-15 Thread Pujo Aji
Hi, your guess still use random.randrange that's make computer doesn't care about whether guess is low or higher than your number.This code should be like this: print \t\t\tWelcome to \Guess My Number\! print \nThink of a number between 1 and 50. print I will try to guess it in as few attempts as

Re: [Tutor] Guess my number game

2005-12-15 Thread Simon Gerber
Hi William, Just a word of warning, you should get used to using 'raw_input()' rather than 'input()' in your progams. Why? Because input() attempts to run whatever you type in as a Python program. If you want to know why that's a problem, try running your progam. When it asks you to Enter the

Re: [Tutor] Guess my number game

2005-12-15 Thread Murtog
Try this code: #The Guess My Number Game # #The computer picks a random number between 1 and 50 #The player tries to guess it and the computer lets #the player know if the guess is too high, too low #or right on the money #If the player fails to guess the number after 5 tries #the game ends and

Re: [Tutor] Guess my number game

2005-12-15 Thread Brian van den Broek
Pujo Aji said unto the world upon 2005-12-15 14:52: Hi, your guess still use random.randrange that's make computer doesn't care about whether guess is low or higher than your number. This code should be like this: snip pujo's corrected code Hope this help pujo On 12/15/05, William