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
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
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
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
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
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.
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
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.
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
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
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!')
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 =
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
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
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
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
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
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
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
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
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.
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
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
At 03:16 AM 3/27/2007, Alexander Kapshuk wrote:
Im
working on a program that has the user think of a number between 1 and
100 and then tries to guess that number.
Im having trouble telling the computer to keep on looking for the
correct number, each time narrowing down the search range.
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
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
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
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
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
29 matches
Mail list logo