On 30/07/17 23:36, Borisco Bizaro wrote:
> a=1
> b=2
> while a input ("enter another price :")
Do 'a' or 'b' ever change?
Does 'a print"\n\n press 0 key to stop"
Does the user ever get the chance to enter a value?
If they were, Where is the value stored and is the
value ever used?
>> When rep
2017-05-11 3:53 GMT+02:00 Rafael Skovron :
> Sorry I left out the indents in my previous email. It seems like j is
> always reset to zero. Why does j vary?
>
> Are there two different instances of j going on?
>
>
> for i in range(1, 5):
>
> j=0
>
>while j < i:
>
> print(j, end = "
On Wed, May 10, 2017 at 06:53:21PM -0700, Rafael Skovron wrote:
> Sorry I left out the indents in my previous email. It seems like j is
> always reset to zero. Why does j vary?
Because you run code that adds 1 to j.
> Are there two different instances of j going on?
No. Try to run the code in y
Sorry I left out the indents in my previous email. It seems like j is
always reset to zero. Why does j vary?
Are there two different instances of j going on?
for i in range(1, 5):
j=0
while j < i:
print(j, end = " ")
j += 1
___
While Alan has given you a far better solution, I feel someone should
mention the break statement as you will likely come across it a lot, and it
is quite an important flow control statement.
You could add a break statement to the else which would break out of the
while loop.
https://docs.python.o
On Wed, Dec 10, 2014 at 11:20:12PM -0500, Matthew Nappi wrote:
> I am working on the challenges from “Python Programming for the Absolute
> Beginner” Chapter 3. I am asked to modify the original code pasted below
> to limit the number of guesses a player has to guess the number. I did so
> (code
On 11/12/14 04:20, Matthew Nappi wrote:
(code pasted below); however if a player guesses the right number they
still receive an ending message indicating that they failed. How can I
modify the code without using any advanced techniques to have a different
message in the event of a successful gu
Hello All:
I am working on the challenges from “Python Programming for the Absolute
Beginner” Chapter 3. I am asked to modify the original code pasted below
to limit the number of guesses a player has to guess the number. I did so
(code pasted below); however if a player guesses the right numb
this construct:
On Tue, Jul 15, 2014 at 5:09 AM, Oğuzhan Öğreden
wrote:
>
>
> while time_now < time_finish: # counter and count_until defined
> somewhere above and
> if g_threadStop.is_set() == False:
> # return something or raise an exception to signal
> ite
Apologies, I didn't answer your question.
while time_now < time_finish: # counter and count_until defined
somewhere above and
if g_threadStop.is_set() == False:
# return something
Thread methods are typically void, meaning they return nothing. At least
this is
So if I understand this correctly, you want to start a thread and then stop
it after a certain time period?
Here's an adapted example that includes a timer. (I believe in learning by
example where possible)
With that said, if it were my code going into production I'd move the timer
logic out of th
Thanks!
I'll have a side question. If I implement this idea to my case,
threadWorker() would look like this:
def threadWorker(_arg1, _arg2):
print("Starting worker thread with args: %s, %s" % (_arg1, _arg2))
while g_threadStop.is_set() == False:
## here comes a for loop:
OK, so I mocked up an example now...
import time
import threading
g_threadStop = threading.Event()
def threadWorker(_arg1, _arg2):
print("Starting worker thread with args: %s, %s" % (_arg1, _arg2))
while(not g_threadStop.is_set()):
print("Thread running.")
time.sleep(1)
Multi-threading takes practice!
Are you using an event object to signal the thread should exit? I'm
guessing you're just using a bool which is why it does not work.
See: https://docs.python.org/3.4/library/threading.html#event-objects
I'm very short on time and the moment and therefore can't moc
Hi,
I've been practicing with multithreading and gtk for a while and recently
have observed something I can't quite grasp.
This is basically a timer with a settings window and a countdown window
which is produced after setting_window passes necessary arguments to thread.
I have a while loop whic
On Sat, Jul 12, 2014 at 02:39:12PM +0200, Wolfgang Maier wrote:
[...]
> Very interesting advice. Wasn't aware at all of this feature of casefold.
> As a native German speaker, I have to say that your last two examples
> involving the capital ß are pretty contrived: although the capital ß is
> par
On 12/07/14 13:19, Steven D'Aprano wrote:
Because the person might have typed any of:
grosse
große
etc., and you want to accept them all, just like in English
The bit I was missing was that a German user might use the ss version
instead the ß so testing for either of them alone is insuffi
On 12.07.2014 14:20, Dave Angel wrote:
I don't remember my high school German enough to remember if the ß
character is an example, but in various languages there are
characters that exist only in uppercase, and whose lowercase
equivalent is multiple letters. Or vice versa. And characters
On 12.07.2014 14:19, Steven D'Aprano wrote:
On Sat, Jul 12, 2014 at 11:27:17AM +0100, Alan Gauld wrote:
On 12/07/14 10:28, Steven D'Aprano wrote:
If you're using Python 3.3 or higher, it is better to use
message.casefold rather than lower. For English, there's no real
difference:
...
but it ca
Thank you guys! Works perfectly! :D
Regards,
Steve Rodriguez
On Sat, Jul 12, 2014 at 1:21 AM, Peter Otten <__pete...@web.de> wrote:
> Peter Otten wrote:
>
> > PS: You sometimes see
> >
> > message in "qQ"
> >
> > but this is buggy as it is true when the message is either
> > "q", "Q", or "qQ".
Hi Steve,
In your conditionals:
…
while message != 'q' or 'Q'/message != “q” or message != “Q”:
…
Python will only match the first variable. A better approach (which might be a
good solution) would be capturing the exit commands in a list like this:
JL’s code:
while message not in [“q”, “Q”]
Steven D'Aprano Wrote in message:
> On Sat, Jul 12, 2014 at 09:33:20AM +0100, Alan Gauld wrote:
>
>> 2) Better (IMHO) is to convert message to lower case (or upper if
>> you prefer) and only do one comparison:
>>
>> while message.lower() != 'q':
>
> I second this advice, but with a slight modif
On Sat, Jul 12, 2014 at 11:27:17AM +0100, Alan Gauld wrote:
> On 12/07/14 10:28, Steven D'Aprano wrote:
>
> >If you're using Python 3.3 or higher, it is better to use
> >message.casefold rather than lower. For English, there's no real
> >difference:
> >...
> >but it can make a difference for non-E
On 12/07/14 10:28, Steven D'Aprano wrote:
If you're using Python 3.3 or higher, it is better to use
message.casefold rather than lower. For English, there's no real
difference:
...
but it can make a difference for non-English languages:
py> "Große".lower() # German for "great" or "large"
'groß
On Sat, Jul 12, 2014 at 09:33:20AM +0100, Alan Gauld wrote:
> 2) Better (IMHO) is to convert message to lower case (or upper if
> you prefer) and only do one comparison:
>
> while message.lower() != 'q':
I second this advice, but with a slight modification.
If you're using Python 3.3 or higher,
On 11/07/14 22:16, Steve Rodriguez wrote:
Hey guys n gals,
New to python, having some problems with while loops, I would like to
make a program quick once q or Q is typed, but thus far I can only get
the first variable to be recognized.
> My code looks like:
>
> message = raw_input("-> ")
Peter Otten wrote:
> PS: You sometimes see
>
> message in "qQ"
>
> but this is buggy as it is true when the message is either
> "q", "Q", or "qQ".
Oops, I forgot "".
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription option
Steve Rodriguez wrote:
> Hey guys n gals,
>
> New to python, having some problems with while loops, I would like to make
> a program quick once q or Q is typed, but thus far I can only get the
> first variable to be recognized. My code looks like:
>
> message = raw_input("-> ")
> while m
Hey guys n gals,
New to python, having some problems with while loops, I would like to make
a program quick once q or Q is typed, but thus far I can only get the first
variable to be recognized. My code looks like:
message = raw_input("-> ")
while message != 'q':
s.send(message)
On 18/05/14 23:44, Sam Ball wrote:
I however would like to add in another line that tells the user their account
is invalid
before looping around and asking them to re enter their account.
OK, Time to introdusce another Pyhon idioM, the break clause.
while True: # loop forever
get inpu
----
> Date: Wed, 14 May 2014 16:16:45 -0400
> From: d...@davea.name
> To: tutor@python.org
> Subject: Re: [Tutor] While Loop?
>
> On 05/14/2014 05:45 AM, Sam Ball wrote:
>> I'm attempting to create a program where the user inputs
On 05/14/2014 05:45 AM, Sam Ball wrote:
I'm attempting to create a program where the user inputs their account number
(which must be 8 digits) and if what the user enters is not 8 digits in length
I want python to tell the user this is invalid and then keep asking for the
account number until
On Wed, May 14, 2014 at 2:45 AM, Sam Ball wrote:
> I'm attempting to create a program where the user inputs their account
> number (which must be 8 digits) and if what the user enters is not 8 digits
> in length I want python to tell the user this is invalid and then keep
> asking for the account
On 14/05/14 10:45, Sam Ball wrote:
I'm attempting to create a program where the user inputs their account
number (which must be 8 digits) and if what the user enters is not 8
digits in length I want python to tell the user this is invalid and then
keep asking for the account number until a suitab
I'm attempting to create a program where the user inputs their account number
(which must be 8 digits) and if what the user enters is not 8 digits in length
I want python to tell the user this is invalid and then keep asking for the
account number until a suitable number has been entered.
I'm g
On 01/04/14 00:22, Scott Dunning wrote:
def print_n(s,n):
i = 0
while i < n:
print s,
i += 1
print_n('a',3)
Also, with this exercise it’s using a doctest so I don’t actually call the
function
I have no idea what you mean buy this?
There is no doctest above and yo
Scott Dunning Wrote in message:
>
> On Mar 31, 2014, at 5:15 AM, Dave Angel wrote:
>>
>> Do you know how to define and initialize a second local variable?
>> Create one called i, with a value zero.
>>
>> You test expression will not have a literal, but compare the two
>> locals. And the st
On Mar 31, 2014, at 5:15 AM, Dave Angel wrote:
>
> Do you know how to define and initialize a second local variable?
> Create one called i, with a value zero.
>
> You test expression will not have a literal, but compare the two
> locals. And the statement that increments will change i, not
On Mar 31, 2014, at 1:39 AM, Mark Lawrence wrote:
>
> They say that the truth hurts, so if that's the best you can come up with, I
> suggest you give up programming :(
You’re in the TUTOR section. People in here are new to programming. I’ve only
been doing this for a couple months and I just
On Mar 31, 2014, at 2:01 AM, Alan Gauld wrote:
>
> Incidentally, your assignment does not appear to require
> a while loop, just iteration? If thats the case you could
> use a for loop instead and it would actually be more
> suitable. Have you covered for loops yet?
>
No, we haven’t got to fo
* Scott Dunning [2014-03-30 18:37]:
> Without out a break or placing that 10 in there I can’t think of a way
> to have the while loop stop once it reaches (n). Any hints?
As discussed already, you can't use fixed values (ie, you don't know
that 10 is always going to be there).
> def print_n(s
Scott Dunning Wrote in message:
>
> On Mar 30, 2014, at 4:29 AM, Dave Angel wrote:
>>
>> You're getting closer. Remember that the assignment shows your
>> function being called with 10, not zero. So you should have a
>> separate local variable, probably called I, which starts at
>> zero, a
On 31/03/14 03:13, Scott Dunning wrote:
separate local variable, probably called I, which starts at
zero, and gets incremented each time.
The test in the while should be comparing them.
So, this is what I have now and it ‘works’
It doesn't work because they are all on the same line.
But al
On 31/03/14 02:37, Scott Dunning wrote:
You're getting closer. Remember that the assignment shows your
function being called with 10, not zero. So you should have a
separate local variable, probably called I, which starts at
zero, and gets incremented each time.
Without out a break or pla
On 31/03/2014 03:13, Scott Dunning wrote:
On Mar 30, 2014, at 4:29 AM, Dave Angel wrote:
You're getting closer. Remember that the assignment shows your
function being called with 10, not zero. So you should have a
separate local variable, probably called I, which starts at
zero, and gets
On Mar 30, 2014, at 4:29 AM, Dave Angel wrote:
>
> You're getting closer. Remember that the assignment shows your
> function being called with 10, not zero. So you should have a
> separate local variable, probably called I, which starts at
> zero, and gets incremented each time.
>
> The te
On Mar 30, 2014, at 4:29 AM, Dave Angel wrote:
>
>
> You're getting closer. Remember that the assignment shows your
> function being called with 10, not zero. So you should have a
> separate local variable, probably called I, which starts at
> zero, and gets incremented each time.
The exer
Scott Dunning Wrote in message:
>
> On Mar 29, 2014, at 12:47 AM, Dave Angel wrote:
>>
>> So did your code print the string 10 times? When asking for help,
>> it's useful to show what you tried, and what was expected, and
>> what actually resulted.
>>
>> You use * to replicate the string,
On 30/03/14 02:36, Scott Dunning wrote:
Your while loop doesn't quit after 10 times, it keeps going. Can
you figure out why?
This works without a break.
> Is this more a long the line of what the excercise was
> looking for you think?
Yes.
while n <= 10:
print s
n =
On Mar 29, 2014, at 12:47 AM, Dave Angel wrote:
>
> So did your code print the string 10 times? When asking for help,
> it's useful to show what you tried, and what was expected, and
> what actually resulted.
>
> You use * to replicate the string, but that wasn't what the
> assignment aske
On Mar 29, 2014, at 12:47 AM, Dave Angel wrote:
>
> What are you uncertain about, assert or isinstance? Such
> statements are frequently used to make sure the function
> arguments are of the right type.
I’m not sure exactly what it’s doing. I guess I need to read up on it again.
>
>>
>>
>
On Mar 28, 2014, at 10:36 PM, Ben Finney wrote:
>
> A good programming exercise will show an example input and the expected
> output, to give an unambiguous test case. Does the homework have that?
This is what the exercise has as examples…
"""Print the string `s`, `n` times.
Parameter
Scott W Dunning Wrote in message:
>
> On Mar 28, 2014, at 9:54 PM, Scott W Dunning wrote:
>
>> Hello, Iâm working on some practice exercises from my homework and Iâm
>> having some issues figuring out what is wanted.
>>
>> Weâre working with the while loop and this is what the questi
On 03/29/2014 01:18 AM, Scott W Dunning wrote:
On Mar 28, 2014, at 9:54 PM, Scott W Dunning wrote:
Hello, I’m working on some practice exercises from my homework and I’m having
some issues figuring out what is wanted.
We’re working with the while loop and this is what the question states;
Hello, I’m working on some practice exercises from my homework and I’m having
some issues figuring out what is wanted.
We’re working with the while loop and this is what the question states;
Write a function print_n that prints a string n times using iteration.
"""Print the string `s`
Scott W Dunning writes:
> On Mar 28, 2014, at 9:54 PM, Scott W Dunning wrote:
>
> > We’re working with the while loop and this is what the question states;
> >
> > Write a function print_n that prints a string n times using iteration.
> This is what I have so far but I’m not really sure it’s wh
On Mar 28, 2014, at 9:54 PM, Scott W Dunning wrote:
> Hello, I’m working on some practice exercises from my homework and I’m having
> some issues figuring out what is wanted.
>
> We’re working with the while loop and this is what the question states;
>
> Write a function print_n that prints
# skip 5
if count == 5:
continue # means "Jump back to the top of the looop"
It is the reason. You yourself have mentioned it right inside the code!
On 7 April 2013 09:40, Dave Angel wrote:
> On 04/06/2013 11:23 PM, Najam Us Saqib wrote:
>
>> Hi,
>>
>> Would you please help me by e
On 04/06/2013 11:23 PM, Najam Us Saqib wrote:
Hi,
Would you please help me by explaining that why " 5 " is skipped and not
printed in the following program?
Seems to me the comments say it pretty well. The continue statement
causes execution to continue at the while statement, which has th
On 04/06/2013 11:23 PM, Najam Us Saqib wrote:
Hi,
Would you please help me by explaining that why " 5 " is skipped and not
printed in the following program?
Seems to me the comments say it pretty well. The continue statement
causes execution to continue at the while statement, which has th
Hi,
Would you please help me by explaining that why " 5 " is skipped and not
printed in the following program?
Thank you.
Najam.
count = 0
while True:
count += 1
# end loop if count is greater than 10
if count > 10:
break # means "break out of the loop"
# skip 5
if c
On 06/13/2012 01:29 AM, Andrew Brunn wrote:
> Let me preface by saying that I am currently taking my first programming
> class; so I have been a "programmer" for just over a week now.
>
> Here is my question;
>
> I
> am trying to create a while loop that will allow me ask for a username
> and pa
Let me preface by saying that I am currently taking my first programming
class; so I have been a "programmer" for just over a week now.
Here is my question;
I
am trying to create a while loop that will allow me ask for a username
and password. If a wrong username and password is entered, I wo
Hi again,
On 2 January 2012 06:28, Steven D'Aprano wrote:
>> Another answer is to use Decimal class, which CAN represent decimal values
>> exactly.
>
>
> That only applies to decimal values which can be represented using a fixed
> number of decimal places. So 1/5 is fine, and is 0.2 exactly, but
(You accidentally forgot to include the list when you replied. The
easiest way (for most people) to avoid that is to use Reply-all)
On 01/02/2012 01:00 AM, Sarma Tangirala wrote:
On 2 Jan 2012 08:56, "Dave Angel" wrote:
Easiest answer is to use integers. Scale everything up by a factor of
Hi Steven,
On 2 January 2012 06:28, Steven D'Aprano wrote:
> That only applies to decimal values which can be represented using a fixed
> number of decimal places. So 1/5 is fine, and is 0.2 exactly, but 1/3 is
> not, since it would require an infinite number of decimal places.
Just a small nit
Dave Angel wrote:
Easiest answer is to use integers. Scale everything up by a factor of
100, and you won't need floats at all. Just convert when printing (and
even then you may get into trouble).
Another answer is to use Decimal class, which CAN represent decimal
values exactly.
That onl
On Mon, Jan 2, 2012 at 3:48 AM, brian arb wrote:
> Hello,
> Can some please explain this to me?
> My while loop should continue while "owed" is greater than or equal to "d"
>
> first time the function is called
> the loop exits as expected
> False: 0.00 >= 0.01
> the next time it does not
On 01/01/2012 09:48 PM, brian arb wrote:
Hello,
Can some please explain this to me?
My while loop should continue while "owed" is greater than or equal to "d"
first time the function is called
the loop exits as expected
False: 0.00>= 0.01
the next time it does not
False: 0.01>= 0.010
Hello,
Can some please explain this to me?
My while loop should continue while "owed" is greater than or equal to "d"
first time the function is called
the loop exits as expected
False: 0.00 >= 0.01
the next time it does not
False: 0.01 >= 0.01
Below is the snippet of code, and th
mustafa akkoc wrote:
hello i have syntax problem in this program
After correcting the indentations, and putting a missing parentheses in
line 24 (the last line), I don't see any Syntax Error.
#!/usr/bin/python
# Filename: while.py
number = 23
running = True
while running :
guess= i
"mustafa akkoc" wrote
hello i have syntax problem in this program
#!/usr/bin/python
# Filename: while.py
number = 23
running = True
while running :
guess= input('Enter an integer : ') # it give a syntax error this
line can
you me ?
Always post the full text of error messages please. It h
hello i have syntax problem in this program
#!/usr/bin/python
# Filename: while.py
number = 23
running = True
while running :
guess= input('Enter an integer : ') # it give a syntax error this line can
you me ?
if guess == number:
print('Congratulations, you guessed it.')
running = False # this c
Thank you John & Allen,
See the loops section of my tutorial for more about for
and while loops.
Yes, great tutorial, just getting it to sink in, now thats the problem :)
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/
"David" <[EMAIL PROTECTED]> wrote
Hi, I am trying to get a while loop that will execute 5 time then
stop.
Copngratulations, you have succeeded.
Unfortunately nothing happens inside your loop. I suspect you
actually want to execute some code 5 times?
#counter = 0
#while counter < 5 :
#cou
On 08/07/2008, David <[EMAIL PROTECTED]> wrote:
> Hi, I am trying to get a while loop that will execute 5 time then stop.
Hi David,
The standard pattern is like this:
i = 0
while i < 5:
# the stuff you want to do goes here
i = i + 1
Note that if you know exactly how many times you will
Hi, I am trying to get a while loop that will execute 5 time then stop.
#!/usr/bin/python
# Filename myfirstclass.py
#
# A Little digital clock
from time_class import Time
import sys
import time
mytime = Time()
print "Can you tell me the time (24h)?"
hour = input("Give the hour: ")
minute = in
> -Original Message-
> Subject: Re: [Tutor] while Loop
>
> Oops, didn't notice the uppercase U, thanks Luke.
>
> - Original Message -
> Subject: Re: [Tutor] while Loop
>
>
> >> define it with usedPocketsOne = 192000?
> > no, I
Oops, didn't notice the uppercase U, thanks Luke.
- Original Message -
From: "Luke Paireepinart" <[EMAIL PROTECTED]>
To: "Darren Williams" <[EMAIL PROTECTED]>
Cc:
Sent: Wednesday, July 18, 2007 3:08 PM
Subject: Re: [Tutor] while Loop
> Darren
Darren Williams wrote:
> Luke and Kent, you're right, I didn't think JavaScript calculated
> multiplaction and division before addition and subtraction but seems
> it does :)
>
> I dunno what you mean about usedPocketsOne not being defined, didn't I
> define it with usedPocketsOne = 192000?
no,
age -
From: "Luke Paireepinart" <[EMAIL PROTECTED]>
To: "Darren Williams" <[EMAIL PROTECTED]>
Cc:
Sent: Wednesday, July 18, 2007 11:57 AM
Subject: Re: [Tutor] while Loop
> Darren Williams wrote:
>> Hi all,
>> I'm writing a calculator for
Darren Williams wrote:
> Hi all,
>
> I'm writing a calculator for an online game that I used to play but
> don't seem to be able to break out of the while loop, the program will
> just go over and over the loop, crashing the program and I don't know
> if Python is just really slow at this type
Darren Williams wrote:
> Hi all,
>
> I'm writing a calculator for an online game that I used to play but
> don't seem to be able to break out of the while loop, the program will
> just go over and over the loop, crashing the program and I don't know if
> Python is just really slow at this type
Hi all,
I'm writing a calculator for an online game that I used to play but don't seem
to be able to break out of the while loop, the program will just go over and
over the loop, crashing the program and I don't know if Python is just really
slow at this type of thing or i'm doing it completely
in understanding while loop someone should understand "if conditional" first.In "If conditional" there are common relational symbol "and" and "or"Let's discuss "and" conditional
Condition 1 Condition 2 ResultTrue True TrueTrue F
> From: John Joseph <[EMAIL PROTECTED]>
>I am trying to use while loop , here I want
> while loop to check for two conditions , I am not
> getting an idea how to use while loop for checking
> two conditions
> I used "&" condition , but it is not
> giving me the expect
Hi
>while (condition no 1) & (condition no2):
> print "Results"
>
While (condition no 1) and (condition no2):
print "Results"
in python you use the words
and, or, not, is
like:
if myvar1 is not None and myvar2 == '1':
print 'what a nice snowing day!'
Carlo
what
Hi
I am trying to use while loop , here I want
while loop to check for two conditions , I am not
getting an idea how to use while loop for checking
two conditions
I used "&" condition , but it is not
giving me the expected results
I used in this way
. , hotmail.com> writes:
> I just finished the chapter which includes while loop, if-else-elif
> structure and randrange().
>
> Can anyone suggest me 3 exercises to remind of the chapter?
The standard exercise which includes all three would be a number guessing game
where the computer picks a
Hi,
I just finished the chapter which includes while loop, if-else-elif
structure and randrange().
Can anyone suggest me 3 exercises to remind of the chapter?
Exercises shouldn't be too difficult because i'm newbie!
Looking forward to writing some programs!
Thanks.
__
90 matches
Mail list logo