Re: [Tutor] While loops

2012-07-07 Thread Alan Gauld
On 07/07/12 13:57, myles broomes wrote: I am currently coding a 'text-based adventure game', and im having a bit of trouble with while loops. Here is my code so far: What kind of trouble? You have lots of while loops, which loop? And do you get an error message? If so please post it - all of i

Re: [Tutor] While loops

2012-07-07 Thread Emile van Sebille
On 7/7/2012 5:57 AM myles broomes said... I am currently coding a 'text-based adventure game', and im having a bit of trouble with while loops. Here is my code so far: Please paste in the traceback you're getting, and please set your mail client program for plain text when posting. What I se

Re: [Tutor] while loops

2011-12-14 Thread Prasad, Ramit
-Original Message- From: tutor-bounces+ramit.prasad=jpmorgan@python.org [mailto:tutor-bounces+ramit.prasad=jpmorgan@python.org] On Behalf Of rog capp Sent: Wednesday, December 14, 2011 4:41 PM To: tutor@python.org Subject: [Tutor] while loops # Guess my number # # The computer pi

Re: [Tutor] while loops

2011-12-14 Thread Alan Gauld
On 14/12/11 22:41, rog capp wrote: # Guessing loop while guess != the_number: if guess> the_number: else: guess = int(input("Take a guess: ")) tries += 1 If he/she fails to guess the number after a certain number of attempts then it displays a message about his failure.I

Re: [Tutor] while loops

2011-12-14 Thread Dave Angel
On 12/14/2011 05:41 PM, rog capp wrote: # Guess my number # # The computer picks a random number between 1 and 100 # The player tries to guess it and the computer lets # the player know if the guess is to high, to low # or right on the money import random print("\tWelcome to 'Guess My Number'!

Re: [Tutor] while loops

2011-12-14 Thread Steven D'Aprano
rog capp wrote: [...] # Guessing loop while guess != the_number: if guess > the_number: print("Lowere...") else: print("Higher...") guess = int(input("Take a guess: ")) tries += 1 print("good job") input("\n\nPress the enter key to exit.") This is a program fr

Re: [Tutor] While Loops: Coin Flip Game :p:

2010-11-16 Thread bob gailer
Just for the heck of it: heads = sum(random.randrange(2) for i in range(100)) -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tuto

Re: [Tutor] While Loops: Coin Flip Game :p:

2010-11-16 Thread Alan Gauld
"Stephanie Dawn Samson" wrote thought I should write the rewritten code I got that others helped me get to By applying a couple of other ideas that have been suggested you get something shorter and arguably slightly clearer: # Coin Flips # The program flips a coin 100 times and then # tell

Re: [Tutor] While Loops: Coin Flip Game :p:

2010-11-16 Thread Stephanie Dawn Samson
Greetings, As a thread starter, I thought I should write the rewritten code I got that others helped me get to, since this thread is still going on. # Coin Flips# The program flips a coin 100 times and then# tells you the number of heads and tailsimport random print "\a"print "\tWelcome to 'Coi

Re: [Tutor] While Loops: Coin Flip Game :p:

2010-11-16 Thread Nithya Nisha
Thankyou..!!! Regards, Nithya On Tue, Nov 16, 2010 at 1:51 PM, Luke Pettit wrote: > Arrr thats better Nithya it works fine now. I had it working fine before > it was just coming up with that strange result of 73 and 100 > when I copied the code into wing to check it out in order to understand

Re: [Tutor] While Loops: Coin Flip Game :p:

2010-11-16 Thread Luke Pettit
Arrr thats better Nithya it works fine now. I had it working fine before it was just coming up with that strange result of 73 and 100 when I copied the code into wing to check it out in order to understand it. Wing picked up the spacing and I had already corrected that Dave as I was simply looking

Re: [Tutor] While Loops: Coin Flip Game :p:

2010-11-16 Thread Nithya Nisha
Hi there, This is the Code. Please check it.It is working fine. >>>import random >>>headsCount = 0 >>>tailsCount = 0 >>>count = 1 >>> >>>while count <= 100: >>> coin = random.randrange(2) >>> if coin == 0: >>> headsCount += 1 >>> else: >>> tailsCount += 1

Re: [Tutor] While Loops: Coin Flip Game :p:

2010-11-15 Thread Dave Angel
When I run this code (I'm also a noob) I get this result:- [evaluate lines 1-22 from untitled-1.py] The number of heads was 73 The number of tails was 100 Press the enter key to exit. # Surely, if flipping a single coin 100 times your total number of heads and tails should add up to 100 # not

Re: [Tutor] While Loops: Coin Flip Game :p:

2010-11-15 Thread Nithya Nisha
Hi Tom, Your code is almost correct. Little mistake is there.The random number generate should be in while loop. > import random > > # set the coin > headsCount = 0 > tailsCount = 0 > count = 0 > > # the loop > while count < 100: #If you declare count = 0. The while loo

Re: [Tutor] While Loops: Coin Flip Game :p:

2010-11-15 Thread Luke Pettit
When I run this code (I'm also a noob) I get this result:- >>> [evaluate lines 1-22 from untitled-1.py] The number of heads was 73 The number of tails was 100 Press the enter key to exit. # Surely, if flipping a single coin 100 times your total number of heads and tails should add up to 100 # no

Re: [Tutor] While Loops: Coin Flip Game :p:

2010-11-15 Thread Nithya Nisha
Hi Tom, Your code is almost correct. Little mistake is there.The random number generate should be in while loop. > import random > > # set the coin > headsCount = 0 > tailsCount = 0 > count = 0 > > # the loop > while count < 100: #If you declare

Re: [Tutor] While Loops: Coin Flip Game :p:

2010-11-14 Thread Thomas C. Hicks
On Sun, 14 Nov 2010 17:16:36 -0500 Dawn Samson wrote: > Greetings, > > I'm a Python beginner and working my way through Michael Dawson's > Python Programming for the Absolute Beginner. I'm stuck in a > particular challenge that asks me to write a program that "flips a > coin 100 times and then t

Re: [Tutor] While Loops: Coin Flip Game

2010-11-14 Thread Robert Berman
From: tutor-bounces+bermanrl=cfl.rr@python.org [mailto:tutor-bounces+bermanrl=cfl.rr@python.org] On Behalf Of Dawn Samson Sent: Sunday, November 14, 2010 5:17 PM To: tutor@python.org Subject: [Tutor] While Loops: Coin Flip Game Greetings, I'm a Python beginner and working my way throu

Re: [Tutor] While Loops: Coin Flip Game

2010-11-14 Thread Adam Bark
On 14/11/10 22:16, Dawn Samson wrote: Greetings, I'm a Python beginner and working my way through Michael Dawson's Python Programming for the Absolute Beginner. I'm stuck in a particular challenge that asks me to write a program that "flips a coin 100 times and then tells you the number of he

Re: [Tutor] While Loops: Coin Flip Game

2010-11-14 Thread Stephanie Dawn Samson
Thanks everyone! I should be using algorithms for even such programs at my level. The solution to reiterate the coin flip every time in the loop works. Thanks a lot! Dawn ___ Tutor maillist - Tutor@python.

Re: [Tutor] While Loops: Coin Flip Game

2010-11-14 Thread Steven D'Aprano
Dawn Samson wrote: I've been trying to work on this challenge for a while now and can't get it to work (either it has 100 heads or 100 tails). Unfortunately your code has been mangled in the email, but I can guess your problem: you need to set coin = random.randrange(2) each time through

Re: [Tutor] While Loops: Coin Flip Game

2010-11-14 Thread Hugo Arts
On Sun, Nov 14, 2010 at 11:16 PM, Dawn Samson wrote: > Greetings, > I'm a Python beginner and working my way through Michael Dawson's Python > Programming for the Absolute Beginner. I'm stuck in a particular challenge > that asks me to write a program that "flips a coin 100 times and then tells >

Re: [Tutor] while loops / listeners

2010-06-07 Thread Francesco Loffredo
Hi all, I think that simply erasing those "continue" statements will let Python respond again. Those statements are both useless and damaging, because the following "time.sleep(.1)" statements will NEVER be executed. And this, in turn, is IMHO the reason why Python stops responding: it lacks t

Re: [Tutor] while loops causing python.exe to crash on windows

2010-06-07 Thread Mark Lawrence
On 07/06/2010 01:44, Alex Hall wrote: Further to the other comments that you've had, could you please refer to the following, thanks. http://www.catb.org/~esr/faqs/smart-questions.html Kindest regards. Mark Lawrence ___ Tutor maillist - Tutor@py

Re: [Tutor] while loops causing python.exe to crash on windows

2010-06-07 Thread Walter Prins
On 7 June 2010 02:37, Alex Hall wrote: > I am not sure how else to explain it. I want to loop until the value > of a variable changes, but while that loop is taking place, the user > should be able to perform actions set up in a wx.AcceleratorTable. > Looping, though, causes Windows to tell me th

Re: [Tutor] while loops causing python.exe to crash on windows

2010-06-07 Thread Alan Gauld
"Alex Hall" wrote I am not sure how else to explain it. I want to loop until the value of a variable changes, but while that loop is taking place, the user should be able to perform actions set up in a wx.AcceleratorTable. And here we have the critical clue. You are trying to write this loop

Re: [Tutor] while loops causing python.exe to crash on windows

2010-06-06 Thread bob gailer
On 6/6/2010 9:37 PM, Alex Hall wrote: On 6/6/10, Lie Ryan wrote: On 06/07/10 11:08, Alex Hall wrote: On 6/6/10, bob gailer wrote: On 6/6/2010 8:44 PM, Alex Hall wrote: -- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com;http://www.facebook.c

Re: [Tutor] while loops causing python.exe to crash on windows

2010-06-06 Thread Alex Hall
On 6/6/10, Lie Ryan wrote: > On 06/07/10 11:08, Alex Hall wrote: >> On 6/6/10, bob gailer wrote: >>> On 6/6/2010 8:44 PM, Alex Hall wrote: -- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com;http://www.facebook.com/mehgcap >>> What is your quest

Re: [Tutor] while loops causing python.exe to crash on windows

2010-06-06 Thread Lie Ryan
On 06/07/10 11:08, Alex Hall wrote: > On 6/6/10, bob gailer wrote: >> On 6/6/2010 8:44 PM, Alex Hall wrote: >>> -- >>> Have a great day, >>> Alex (msg sent from GMail website) >>> mehg...@gmail.com;http://www.facebook.com/mehgcap >>> >>> >> What is your question? >> >> >> -- >> Bob Gailer >> 919-6

Re: [Tutor] while loops causing python.exe to crash on windows

2010-06-06 Thread Alex Hall
On 6/6/10, bob gailer wrote: > On 6/6/2010 8:44 PM, Alex Hall wrote: >> -- >> Have a great day, >> Alex (msg sent from GMail website) >> mehg...@gmail.com;http://www.facebook.com/mehgcap >> >> > What is your question? > > > -- > Bob Gailer > 919-636-4239 > Chapel Hill NC > > Why would that code ca

Re: [Tutor] while loops causing python.exe to crash on windows

2010-06-06 Thread bob gailer
On 6/6/2010 8:44 PM, Alex Hall wrote: -- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com;http://www.facebook.com/mehgcap What is your question? -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python

Re: [Tutor] While Loops and Modules

2007-12-06 Thread bhaaluu
Greetings, On Dec 6, 2007 12:44 AM, earlylight publishing <[EMAIL PROTECTED]> wrote: > Hello again to all the wonderfully helpful folks on this list. Today I did > my Google homework and I found this neat bit of code for a countdown timer. > > import time > import threading > class Timer(threadin

Re: [Tutor] while loops

2005-08-08 Thread Will Harris
Thanks for the help guys. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] while loops

2005-08-08 Thread Jay Loden
> coin = random.randrange(2) That's the problem there...you've got coin assigned outside the while loop, so it is assigned 0 or 1 once, before the loop, and then you're running 100 checks on the same value. If you move > coin = random.randrange(2) to inside the while loop before the if state

Re: [Tutor] while loops

2005-08-08 Thread Kent Johnson
Will Harris wrote: > I am working my way through "python programming for the absolute > beginner" and one of the challenges is to create a program that will > flip a coin 100 times and tell you how many of each it did. Now I > have it flipping the coin, but when I try to do this 100 times I end > u