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
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:
>
>
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
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
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
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
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.
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:
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
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
this construct:
On Tue, Jul 15, 2014 at 5:09 AM, Oğuzhan Öğreden oguzhanogre...@gmail.com
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
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
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)
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
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)
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 message !=
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 options:
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(- )
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, it
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ße'
py
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-English
Steven D'Aprano st...@pearwood.info 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
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”,
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.
Oops, I forgot .
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
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
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
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
part
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
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 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
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
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
On Wed, May 14, 2014 at 2:45 AM, Sam Ball sambal...@hotmail.com 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
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 Mar 31, 2014, at 5:15 AM, Dave Angel da...@davea.name 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
Scott Dunning swdunn...@me.com Wrote in message:
On Mar 31, 2014, at 5:15 AM, Dave Angel da...@davea.name 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
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
On Mar 30, 2014, at 4:29 AM, Dave Angel da...@davea.name 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
On 31/03/2014 03:13, Scott Dunning wrote:
On Mar 30, 2014, at 4:29 AM, Dave Angel da...@davea.name 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
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
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
Scott Dunning swdunn...@me.com Wrote in message:
On Mar 30, 2014, at 4:29 AM, Dave Angel da...@davea.name 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,
* Scott Dunning swdunn...@me.com [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).
On Mar 31, 2014, at 2:01 AM, Alan Gauld alan.ga...@btinternet.com 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,
On Mar 31, 2014, at 1:39 AM, Mark Lawrence breamore...@yahoo.co.uk 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
On Mar 28, 2014, at 10:36 PM, Ben Finney ben+pyt...@benfinney.id.au 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`
On Mar 29, 2014, at 12:47 AM, Dave Angel da...@davea.name 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 29, 2014, at 12:47 AM, Dave Angel da...@davea.name 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
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 = n
Scott Dunning swdunn...@me.com Wrote in message:
On Mar 29, 2014, at 12:47 AM, Dave Angel da...@davea.name 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
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`,
On 03/29/2014 01:18 AM, Scott W Dunning wrote:
On Mar 28, 2014, at 9:54 PM, Scott W Dunning scott@cox.net 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
Scott W Dunning scott@cox.net Wrote in message:
On Mar 28, 2014, at 9:54 PM, Scott W Dunning scott@cox.net 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
On Mar 28, 2014, at 9:54 PM, Scott W Dunning scott@cox.net 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
Scott W Dunning scott@cox.net writes:
On Mar 28, 2014, at 9:54 PM, Scott W Dunning scott@cox.net 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
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 count
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 the
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 the
# 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 da...@davea.name wrote:
On 04/06/2013 11:23 PM, Najam Us Saqib wrote:
Hi,
Would you please help
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 password.
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
Hi Steven,
On 2 January 2012 06:28, Steven D'Aprano st...@pearwood.info 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.
(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 Angeld...@davea.name wrote:
Easiest answer is to use integers. Scale everything up
Hi again,
On 2 January 2012 06:28, Steven D'Aprano st...@pearwood.info 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
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 the out
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.01
On Mon, Jan 2, 2012 at 3:48 AM, brian arb brianjames...@gmail.com 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
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
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
mustafa akkoc wrote:
hello i have syntax problem in this program
snip
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 :
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 =
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
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 :
#counter
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
-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 said UsedPocketsOne was not defined. Note the
different
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
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 of
: Luke Paireepinart [EMAIL PROTECTED]
To: Darren Williams [EMAIL PROTECTED]
Cc: tutor@python.org
Sent: Wednesday, July 18, 2007 11:57 AM
Subject: Re: [Tutor] while Loop
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
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, I
Oops, didn't notice the uppercase U, thanks Luke.
- Original Message -
From: Luke Paireepinart [EMAIL PROTECTED]
To: Darren Williams [EMAIL PROTECTED]
Cc: tutor@python.org
Sent: Wednesday, July 18, 2007 3:08 PM
Subject: Re: [Tutor] while Loop
Darren Williams wrote:
Luke and Kent
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
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 is
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 expected results
in understanding while loop someone should understand if conditional first.In If conditional there are common relational symbol and and orLet's discuss and conditional
Condition 1 Condition 2 ResultTrue True TrueTrue False FalseFalse True False
False False FalseIn short, and equal True if and only
. , administrata at 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
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.
86 matches
Mail list logo