On Thu, Dec 20, 2018 at 10:47:44PM +0100, Aine Gormley wrote:
> Hello, could somebody take a quick look at my code? I am unsure why I am
> getting a loop error?
That's hard to do if you don't show us the code :-)
Please COPY AND PASTE (don't try to retype it from memory) the MINIMUM
amount of c
Greetings Aine!
On Thu, Dec 20, 2018 at 6:57 PM Aine Gormley wrote:
>
> Hello, could somebody take a quick look at my code? I am unsure why I am
> getting a loop error?
This is a plain text only list that does not (typically) allow file
attachments. So I do not see any code. So if you wish for
On Mon, Jun 13, 2016 at 6:28 PM Alan Gauld via Tutor
wrote:
> On 13/06/16 08:46, Ek Esawi wrote:
> > Here is a beginner code that might work for you. Best of luck. EK
> >
> > b=[12, 20, 35]
> >
> > for i in range(len(b)):
> > if i==0:
> > c=0
> > else:
> > c=b[i-1]
OPS! This code now produces desired results. I suppose that this works for
smaller blocks. For larger blocks, it might be cumbersome. EK
b=[12, 20, 35]
for i in range(len(b)):
if i==0:
c=0
elif i==2:
c=24
else:
c=b[i-1]
for j in range(c, b[i]):
On 13/06/16 08:46, Ek Esawi wrote:
> Here is a beginner code that might work for you. Best of luck. EK
>
> b=[12, 20, 35]
>
> for i in range(len(b)):
> if i==0:
> c=0
> else:
> c=b[i-1]
> for j in range(c, b[i]):
> print(i+1,j+1)
The problem here is
On Mon, Jun 13, 2016 at 1:33 PM Ek Esawi wrote:
> Here is a beginner code that might work for you. Best of luck. EK
>
> b=[12, 20, 35]
>
> for i in range(len(b)):
> if i==0:
> c=0
> else:
> c=b[i-1]
> for j in range(c, b[i]):
> print(i+1,j+1)
>
If
Here is a beginner code that might work for you. Best of luck. EK
b=[12, 20, 35]
for i in range(len(b)):
if i==0:
c=0
else:
c=b[i-1]
for j in range(c, b[i]):
print(i+1,j+1)
___
Tutor maillist - Tutor@pyth
On 10Jun2016 22:41, Jignesh Sutar wrote:
Is there a better way to code the below than to specify blocks as I have.
Ideally I'd like to specify blocks simply as *blocks=(12,20,35)*
blocks=[(1,12), (13,20), (25,35)]
for i,j in enumerate(blocks):
for x in xrange(blocks[i][0],blocks[i][1]+1):
Sorry, to be a little bit more descriptive. I'd like to loop from 1 to 35
but within this loop there are divisions which I need to prefix that
particular division number.
My output would look like this:
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
2 13
2 14
2 15
2 16
2 17
2 18
2 19
2 20
3 2
On 10/06/16 23:43, Jignesh Sutar wrote:
> Is there a better way to code the below than to specify blocks as I have.
> Ideally I'd like to specify blocks simply as *blocks=(12,20,35)*
>
> blocks=[(1,12), (13,20), (25,35)]
> for i,j in enumerate(blocks):
> for x in xrange(blocks[i][0],blocks[i][
This is pretty cool, Thank you for explaining! I liked the second solution.
Thank you.
On Sunday, July 5, 2015 2:10 AM, Steven D'Aprano
wrote:
Hi Nym, sorry your code's formatting is broken again. I've tried my best
to fix it below:
On Fri, Jul 03, 2015 at 09:04:10PM +, Nym
Hi Nym, sorry your code's formatting is broken again. I've tried my best
to fix it below:
On Fri, Jul 03, 2015 at 09:04:10PM +, Nym City via Tutor wrote:
> Thank to very much for replying. The second solution that you proposed
> worked perfectly:
>
> import csv
> domains = open('top500doma
Thank to very much for replying. The second solution that you proposed worked
perfectly:
import csvdomains = open('top500domains.csv')domainsReader =
csv.reader(domains)domains = ["https://www."; + row[1] for row in
domainsReader]for domain in domains: print(domain) The above solution is
p
On Tue, Jun 30, 2015 at 01:05:13AM +, Nym City wrote:
> Hello all,
> Thank you for your time and tips. The reason why I decided to create a
> loop is because the output is cleaner and did not require any
> formatting. However, based on what I have learned from all of your
> responses, that i
Hello all,
Thank you for your time and tips. The reason why I decided to create a loop is
because the output is cleaner and did not require any formatting. However,
based on what I have learned from all of your responses, that is not going to
work with what I am trying to do.
Here is the updated
Hi Nym, and welcome,
On Sun, Jun 28, 2015 at 07:32:40PM +, Nym City via Tutor wrote:
[...]
> for domain in domainLists:
> something = ("www." + str(domain))
> print(something)
>
> My program reads in a CSV file that has 500 list of domains. However,
> when I save the output of my loop
On 28/06/2015 20:32, Nym City via Tutor wrote:
Hello,
I am working on my second program and its a two part progam that I want to
design However, i am not sure what silly mistake I am making on the first part:
Here is my code:
| 2
3
4
5
6
7 | import csv
domains = open('top500domains.csv')
domain
On 28/06/15 20:32, Nym City via Tutor wrote:
import csv
domains = open('top500domains.csv')
domainsReader = csv.reader(domains)
domainLists = list(domainsReader)
for domain in domainLists:
something = ("www." + str(domain))
You overwrite something each time round the loop.
print(somethi
baidusandy Wrote in message:
[invisible message not copied here]
By posting in html, you managed to pick black on black text. I
literally could see none of your message except the boilerplate.
Please tell your email program to use text mode.
--
DaveA
_
On 22/04/14 17:13, baidusandy wrote:
I'm a newbie to Python. I want to make python useful to my work, to
write a script for get some data out. But there are some setbacks. I
really needs your help. Please, help me.
Its too late for me to study your code properly but here are
a few immediate obs
d
>Sent: Wednesday, 19 March 2014, 22:30
>Subject: Re: [Tutor] loop through hours to calc max and plot
>
>
>
>Could you please give an example of how to put these into a loop in a function
>and create the matching naming conventions?
>
>
>
>
>On Thu, Mar 20, 2014 at 8
On 19/03/14 05:12, questions anon wrote:
I have monthly netcdf files containing hourly temperature data.
I would like to loop through all of the hours and calculate the max for
each hour (00 - 23) and then make a plot.
Its hard to give specific help since I don't know the file format
and most
On 03/13/2014 04:42 PM, Dave Angel wrote:
spir Wrote in message:
On 03/13/2014 12:40 AM, Danny Yoo wrote:
The context is the beginning of the thread:
https://mail.python.org/pipermail/tutor/2014-March/100543.html
with the loop:
###
while health != 0:
...
###
The point, and
OK, thank you. I knew the loop was infinite but usuyally when I did
infinite loops before, I had them print out a message, so it was obvious.
Thanks for the clarification.
On Thu, Mar 13, 2014 at 9:38 AM, spir wrote:
> On 03/13/2014 12:40 AM, Danny Yoo wrote:
>
>> The context is the beginning o
spir Wrote in message:
> On 03/13/2014 12:40 AM, Danny Yoo wrote:
>> The context is the beginning of the thread:
>>
>> https://mail.python.org/pipermail/tutor/2014-March/100543.html
>>
>> with the loop:
>>
>>
>> ###
>> while health != 0:
>> ...
>> ###
>
> The point, and reason why this
On 03/13/2014 12:40 AM, Danny Yoo wrote:
The context is the beginning of the thread:
https://mail.python.org/pipermail/tutor/2014-March/100543.html
with the loop:
###
while health != 0:
...
###
The point, and reason why this loop was (potentially) infinite, is that the
condition
The context is the beginning of the thread:
https://mail.python.org/pipermail/tutor/2014-March/100543.html
with the loop:
###
while health != 0:
...
###
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
htt
On 12/03/2014 23:18, Danny Yoo wrote:
This particular loop condition looks very suspicious. I would look at
it more closely. When is it false? When is it true?
Context please Danny, we're not all mind readers and we don't all have
photographic memories :)
--
My fellow Pythonistas, ask not
This particular loop condition looks very suspicious. I would look at
it more closely. When is it false? When is it true?
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tu
On 11/03/14 13:53, Yanni Phone wrote:
health = 10
trolls = 0
damage = 3
while health != 0:
trolls += 1
health -= damage
This seems simple enough. (This is an example of a non-terminating loop,
by the way, so it is not suppose to work correctly.)
My problem is that when I enter this
On Mon, Dec 2, 2013 at 4:49 PM, eryksun wrote:
> On Mon, Dec 2, 2013 at 1:28 AM, Amit Saha wrote:
>> Indeed, that's a good point. Surprisingly, C does it just fine:
>>
>> # include
>>
>> int main(int argc, char **argv)
>> {
>> float x = 0.0;
>> while(x<1)
>> {
>> x += 0.1;
>>
On 02/12/2013 12:27, Dave Angel wrote:
On Mon, 2 Dec 2013 16:28:38 +1000, Amit Saha wrote:
Indeed, that's a good point. Surprisingly, C does it just fine:
# include
int main(int argc, char **argv)
{
float x = 0.0;
while(x<1)
{
x += 0.1;
printf("%f\n", x);
}
On Mon, 2 Dec 2013 22:57:30 +1000, Amit Saha
wrote:
You missed the fact that I am printing the value of x *after*
incrementing it.
You're quite right, sorry. I'm too accustomed to the usual c idiom,
which would increment the value at the end of the loop.
--
DaveA
On Mon, Dec 2, 2013 at 10:27 PM, Dave Angel wrote:
> On Mon, 2 Dec 2013 16:28:38 +1000, Amit Saha wrote:
>>
>> Indeed, that's a good point. Surprisingly, C does it just fine:
>
>
>
>> # include
>
>
>
>> int main(int argc, char **argv)
>> {
>> float x = 0.0;
>> while(x<1)
>> {
>> x
On Mon, 2 Dec 2013 16:28:38 +1000, Amit Saha
wrote:
Indeed, that's a good point. Surprisingly, C does it just fine:
# include
int main(int argc, char **argv)
{
float x = 0.0;
while(x<1)
{
x += 0.1;
printf("%f\n", x);
}
return 0;
}
gives the following ou
On Mon, Dec 02, 2013 at 04:28:38PM +1000, Amit Saha wrote:
> On Sun, Dec 1, 2013 at 7:26 PM, Steven D'Aprano wrote:
> > Such floating point loops are tricky to get right, thanks to rounding of
> > floats. Observe:
> >
> > py> x = 0.0
> > py> while x < 1.0:
> > ... x += 0.1
> > ...
> > py> x =
On Mon, Dec 2, 2013 at 1:28 AM, Amit Saha wrote:
> Indeed, that's a good point. Surprisingly, C does it just fine:
>
> # include
>
> int main(int argc, char **argv)
> {
> float x = 0.0;
> while(x<1)
> {
> x += 0.1;
> printf("%f\n", x);
> }
>
> return 0;
> }
Python uses
On Mon, Dec 2, 2013 at 4:36 PM, Asokan Pichai wrote:
> On Mon, Dec 2, 2013 at 11:58 AM, Amit Saha wrote:
>>
>> On Sun, Dec 1, 2013 at 7:26 PM, Steven D'Aprano
>> wrote:
>> > On Sun, Dec 01, 2013 at 07:03:15PM +1000, Amit Saha wrote:
>> >> Hello,
>> >>
>> >> Much to my disbelief, I realized I had
On Sun, Dec 1, 2013 at 7:47 PM, spir wrote:
> On 12/01/2013 10:03 AM, Amit Saha wrote:
>>
>> Hello,
>>
>> Much to my disbelief, I realized I hadn't written a program in Python
>> as far as I can recall which required me to do something like this, in
>> psuedocode:
>>
>> x = 0.1
>>
>> for i = 0 to
On Sun, Dec 1, 2013 at 7:14 PM, Dominik George wrote:
> Hi,
>
>> - Do not create a list of the floating point values as i=[0.01, 0.02,
>> 0.03..] - either like that or by using a suitable mathematical formula
>> combined with a list comprehension
>
> You could simply write your own version of xran
On Sun, Dec 1, 2013 at 7:26 PM, Steven D'Aprano wrote:
> On Sun, Dec 01, 2013 at 07:03:15PM +1000, Amit Saha wrote:
>> Hello,
>>
>> Much to my disbelief, I realized I hadn't written a program in Python
>> as far as I can recall which required me to do something like this, in
>> psuedocode:
>>
>> x
On 12/01/2013 10:03 AM, Amit Saha wrote:
Hello,
Much to my disbelief, I realized I hadn't written a program in Python
as far as I can recall which required me to do something like this, in
psuedocode:
x = 0.1
for i = 0 to x step 0.01
# do something with i
end i
Simply stated, I want to start
On 01/12/2013 09:14, Dominik George wrote:
Hi,
- Do not create a list of the floating point values as i=[0.01, 0.02,
0.03..] - either like that or by using a suitable mathematical formula
combined with a list comprehension
You could simply write your own version of xrange that does it, as a
g
On Sun, Dec 01, 2013 at 07:03:15PM +1000, Amit Saha wrote:
> Hello,
>
> Much to my disbelief, I realized I hadn't written a program in Python
> as far as I can recall which required me to do something like this, in
> psuedocode:
>
> x = 0.1
>
> for i = 0 to x step 0.01
> # do something with i
>
Hi,
> - Do not create a list of the floating point values as i=[0.01, 0.02,
> 0.03..] - either like that or by using a suitable mathematical formula
> combined with a list comprehension
You could simply write your own version of xrange that does it, as a
generator:
def xrange_f(start, stop, st
On 17/11/13 01:00, Byron Ruffin wrote:
> When this is run it appears that determineMonthsTilSaved is
> running twice before the loop ends. It is supposed to run
> until saved than goal, but look at the output.
You haven't sent the output, just the code...
> It runs again even after saved goal.
Ajin Abraham wrote:
> Hi,
>I am using a python snippet that will send some data after the data
> length reaches a particular length. So it is supposed to loop and
> periodically sends the data to an email. i am using smtplib to send
> mail. i will attach the code snippet.
>
> def email():
>
On 06/04/13 23:00, Soliman, Yasmin wrote:
I have two questions on these simple programs:
1st why does this loop keep repeating after I enter 'Quit'?
import calendar
m = raw_input(“Enter a year: “)
while m != “Quit”:
if calendar.isleap(int(m)):
print “%d is a leap year” % (int(m))
else:
On 07/04/13 08:00, Soliman, Yasmin wrote:
I have two questions on these simple programs:
1st why does this loop keep repeating after I enter 'Quit'?
The code you give below is not valid Python code. Please copy and paste *actual* the code
you use, do not retype it from memory. I know that it
On 06/04/2013 23:00, Soliman, Yasmin wrote:
I have two questions on these simple programs:
1st why does this loop keep repeating after I enter 'Quit'?
import calendar
m = raw_input(“Enter a year: “)
while m != “Quit”:
if calendar.isleap(int(m)):
print “%d is a leap year” % (int(m))
else:
On 04/06/2013 06:00 PM, Soliman, Yasmin wrote:
I have two questions on these simple programs:
>
> 1st why does this loop keep repeating after I enter 'Quit'?
>
> import calendar
> m = raw_input(“Enter a year: “)
> while m != “Quit”:
> if calendar.isleap(int(m)):
> print “%d is a leap year” %
On 16/03/2013 04:08, Vincent Balmori wrote:
I am trying to loop a simple exception. I tried to put a while loop, but
I keep getting syntax issues. I also tried to alternatively use
something on the lines of "while number != int" also with no avail.
Please help us to help you. What did your whi
On 16 March 2013 05:08, Vincent Balmori wrote:
> I am trying to loop a simple exception. I tried to put a while loop, but I
> keep getting syntax issues. I also tried to alternatively use something on
> the lines of "while number != int" also with no avail.
It would help if you:
a) didn't send HTM
On 05/29/2012 08:46 PM, Joseph Rishe wrote:
> #Operating System - Mac OS X 10.6.8
> #Python Version - Python 2.6.6
>
>
>
> ##Goal: I am creating a program to calculate credit card payments.
> ## The user should be able to put in a credit card balance and
> interest
> ## rate, and the p
Surya K wrote:
I am on windows. So, as msvcrt is for windows, I wonder if there
is any module that works for both,
http://code.activestate.com/recipes/577977
--
Steven
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription opt
On 2012/01/30 07:20 AM, Surya K wrote:
I want to run code until a "enter" is pressed. Well, it shouldn't wait
for the user to enter "enter"
This is my code:
import msvcrt
chr = 0
while chr != 'q':
print "my code",
if msvcrt.kbhit():
chr = msvcrt.getch()
This isn't workin
On 30/01/12 05:20, Surya K wrote:
I want to run code until a "enter" is pressed. Well, it shouldn't wait
for the user to enter "enter"
This is my code:
import msvcrt
chr = 0
while chr != 'q':
print "my code",
if msvcrt.kbhit():
chr = msvcrt.getch()
You shouldn't need the kbhit test.
Try jus
Surya K wrote:
> I want to run code until a "enter" is pressed. Well, it shouldn't wait for
> the user to enter "enter" This is my code:
This is what it looks like over here:
> import msvcrtchr = 0while chr != 'q': print "my code", if
> msvcrt.kbhit(): chr = msvcrt.getch()
Th
"Vincent Balmori" wrote
you the number of heads and tails." Right now I am
having trouble connecting the random.randint function
into the loop.
Break the problem statement down.
You have correctly worked out that randint(1,2) will equate
to tossing the coin.
You want to do that 100 times
Vincent,
You will need to move the line that flips the coin:
coin = random.randint(1,2)
and the if/else logic *inside* the loop so it will be repeated as many
times as needed.
I'm not sure what you want to do with the input() inside the loop. Remove this.
Alex
2011/6/4 Vincent Balmori :
> H
hi,
thanks for the feedback, it is much appreciated.
On Fri, May 21, 2010 at 7:54 PM, bob gailer wrote:
> Also note that the database function creates a local variable "database" but
> does nothing with it.
> When the function terminates that variable is lost.
> Did you intend to return it?
yes,
Also note that the database function creates a local variable "database"
but does nothing with it.
When the function terminates that variable is lost.
Did you intend to return it?
Also it is not good practice to use the same name for a function and a
variable.
--
Bob Gailer
919-636-4239
Chapel
On 5/21/2010 5:35 AM, Norman Khine wrote:
hello,
i have this script, but i am stuck at the loop, if the user types an
incorrect database id:
http://paste.lisp.org/+25D3
how would i write the exception correctly?
Which line of code could raise the ValueError exception?
That line should be
thanks Steve, this response came handy.
I would have to take this home and read. if i encounter difficulties,
I'd get back to the house.
I'm grateful.
If I get more explanations though, it would be great.
Regards,
On 5/18/10, Steve Willoughby wrote:
> I'm changing the subject line because this is
Dave Angel, 17.04.2010 10:47:
Alan Gauld wrote:
"Lie Ryan" wrote
A friend of mine suggested me to do the next experiment in python
and Java.
It's a simple program to sum all the numbers from 0 to 10.
result = i = 0
while i < 10:
result += i
i += 1
print result
Are you sure
Alan Gauld wrote:
"Lie Ryan" wrote
A friend of mine suggested me to do the next experiment in python
and Java.
It's a simple program to sum all the numbers from 0 to 10.
result = i = 0
while i < 10:
result += i
i += 1
print result
Are you sure you're not causing Ja
Hi.
Thanks for everyone answers. It's true, hehe, it's not a benchmark
or anything like that. I hadn't taken into account compiler
optimizations, but I have learnt a lot in this thread.
About the Java code, Bigints are used.
ark
___
Tutor maillist -
"Lie Ryan" wrote
A friend of mine suggested me to do the next experiment in python and Java.
It's a simple program to sum all the numbers from 0 to 10.
result = i = 0
while i < 10:
result += i
i += 1
print result
Are you sure you're not causing Java to overflow here?
> result = sum(range(10))
>
> although it still took 10 minutes on my PC.
Did you mean to say "minutes" or rather "seconds" here? And did you
really mean to use "range" or rather "xrange" (or "range" in Py3)?
Yes, minutes and in Python 3.
And on a 2.8GHz 2 core CPU with 2G RAM
su
"Steven D'Aprano" wrote
(We can of course do some fancy math to speed this particular
sum up since the result for any power of ten has a common pattern,
but I wouldn't expect the compiler optimiser to be that clever)
No fancy maths needed,
The sum of 1,2,3,4,...,N is given by a simple for
ALAN GAULD wrote:
The precalculation optimisations are
taking place. If you pass it an argument to use for the upper limit of the
sequence the calculation time shoots up.
I'm still confused about when the addition takes place.
Surely the compiler has to do the addition, so it should
On 04/16/10 16:50, Ark wrote:
> Hi everyone.
> A friend of mine suggested me to do the next experiment in python and Java.
>
> It's a simple program to sum all the numbers from 0 to 10.
>
> result = i = 0
> while i < 10:
> result += i
> i += 1
> print result
>
Are you su
Steven D'Aprano, 16.04.2010 12:00:
On Fri, 16 Apr 2010 06:29:40 pm Alan Gauld wrote:
"Stefan Behnel" wrote
import cython
@cython.locals(result=cython.longlong, i=cython.longlong)
def add():
result = 0
for i in xrange(10):
result += i
On Fri, 16 Apr 2010 06:25:54 pm Stefan Behnel wrote:
> Alan Gauld, 16.04.2010 10:09:
> > Even the built in sum() will be faster than a while loop:
> >
> > result = sum(range(10))
> >
> > although it still took 10 minutes on my PC.
>
> Did you mean to say "minutes" or rather "seconds" here?
On Fri, 16 Apr 2010 06:29:40 pm Alan Gauld wrote:
> "Stefan Behnel" wrote
>
> > import cython
> >
> > @cython.locals(result=cython.longlong, i=cython.longlong)
> > def add():
> > result = 0
> > for i in xrange(10):
> > result += i
> > return
> The precalculation optimisations are
> taking place. If you pass it an argument to use for the upper limit of the
> sequence the calculation time shoots up.
I'm still confused about when the addition takes place.
Surely the compiler has to do the addition, so it should be slower?
I assume
Alan Gauld, 16.04.2010 10:29:
"Stefan Behnel" wrote
import cython
@cython.locals(result=cython.longlong, i=cython.longlong)
def add():
result = 0
for i in xrange(10):
result += i
return result
print add()
This runs in less than half a second on my machine, includin
Dave Angel wrote:
Christian Witts wrote:
Ark wrote:
Hi everyone.
A friend of mine suggested me to do the next experiment in python
and Java.
It's a simple program to sum all the numbers from 0 to 10.
result = i = 0
while i < 10:
result += i
i += 1
print result
The
Alan Gauld wrote:
"Stefan Behnel" wrote
import cython
@cython.locals(result=cython.longlong, i=cython.longlong)
def add():
result = 0
for i in xrange(10):
result += i
return result
print add()
This runs in less than half a second on
Stefan Behnel, 16.04.2010 09:38:
A compiler for a statically compiled language can see that the
above loop yields a constant result, so it can calculate the result in
advance (or at least reduce the loop overhead for the calculation)
instead of generating code for the loop as it stands.
That re
Christian Witts wrote:
Ark wrote:
Hi everyone.
A friend of mine suggested me to do the next experiment in python and
Java.
It's a simple program to sum all the numbers from 0 to 10.
result = i = 0
while i < 10:
result += i
i += 1
print result
The time for this calc
"Stefan Behnel" wrote
import cython
@cython.locals(result=cython.longlong, i=cython.longlong)
def add():
result = 0
for i in xrange(10):
result += i
return result
print add()
This runs in less than half a second on my machine, inclu
Alan Gauld, 16.04.2010 10:09:
Even the built in sum() will be faster than a while loop:
result = sum(range(10))
although it still took 10 minutes on my PC.
Did you mean to say "minutes" or rather "seconds" here? And did you really
mean to use "range" or rather "xrange" (or "range" in
"Ark" wrote
It's a simple program to sum all the numbers from 0 to 10.
result = i = 0
while i < 10:
result += i
i += 1
print result
The time for this calculations was huge. It took a long time to give
the result. But, the corresponding program in Java takes less than
Ark wrote:
Hi everyone.
A friend of mine suggested me to do the next experiment in python and Java.
It's a simple program to sum all the numbers from 0 to 10.
result = i = 0
while i < 10:
result += i
i += 1
print result
The time for this calculations was huge. It took
Ark, 16.04.2010 08:50:
A friend of mine suggested me to do the next experiment in python and Java.
It's a simple program to sum all the numbers from 0 to 10.
result = i = 0
while i< 10:
result += i
i += 1
print result
I hope you are aware that this is a) a very lous
Nathan Wing escribió:
Hello All,
I've been racking my brain trying to figure out, what I imagine to be,
a very simple problem. I found the Intro to comp science MIT open
course
(http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-00Fall-2007/CourseHome/index.htm)
and was
Nathan Wing wrote:
Hello All,I've been racking my brain trying to figure out, what I imagine to
be, a very simple problem. I found the Intro to comp science MIT open
course (
http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-00Fall-2007/CourseHome/index.htm)
and was working
On Thu, Mar 12, 2009 at 11:41 AM, spir wrote:
> Le Thu, 12 Mar 2009 11:13:33 -0400,
> Kent Johnson s'exprima ainsi:
>
>> Because local name lookup is faster than global name lookup. Local
>> variables are stored in an array in the stack frame and accessed by
>> index. Global names are stored in a
Le Thu, 12 Mar 2009 11:13:33 -0400,
Kent Johnson s'exprima ainsi:
> Because local name lookup is faster than global name lookup. Local
> variables are stored in an array in the stack frame and accessed by
> index. Global names are stored in a dict and accessed with dict access
> (dict.__getitem__
On Thu, Mar 12, 2009 at 8:13 AM, Poor Yorick
wrote:
> In the following snippet, the loop in the global namespace takes twice as
> long
> as the loop in the function namespace. Why?
Because local name lookup is faster than global name lookup. Local
variables are stored in an array in the stack fr
wormwood_3 wrote:
> Kent,
>
> You replied with the following some time ago regarding a question I asked
> about optimizing a loop:
>
>>> You should try an optimized for loop:
>>> append_ = self.potdomains.append_
>>> s1_ = suffix1
>>>
Kent,
You replied with the following some time ago regarding a question I asked about
optimizing a loop:
>> You should try an optimized for loop:
>> append_ = self.potdomains.append_
>> s1_ = suffix1
>> s2_ = suffix2
>>
wormwood_3 wrote:
> I ran a few tests, with the following results:
>
> 1. Timing using the time module:
>* Using for loop, src code:
> import time
> start = time.time()
> for word in self.dictcontents:
> se
I ran a few tests, with the following results:
1. Timing using the time module:
* Using for loop, src code:
import time
start = time.time()
for word in self.dictcontents:
self.potdomains.append(word + suffix
>I think what you have is pretty clear. I can't think of a way to do this
>with a single list comprehension because you add two items to the list
>each time through the loop. You could use a list comp and a generator
>expression, but the order of entries in the result will be different:
>self.po
wormwood_3 wrote:
> Hello tutors,
>
> I am trying to understand the best cases in which to use for loops,
list comprehensions, generators, and iterators. I have a rather simple
process that I made initially as a for loop:
>
> self.potdomains = []
> for word in self.dictcontents:
>
ron wrote:
> ok, this code is written with vi:
>
> #/usr/bin/env python
>
This should be #! not just #, that makes it a regular comment.
> #foreach.py
>
> myList = [1,2,3,4]
> for index in range(len(myList)):
> myList[index] += 1
> print myList
> ~
>
> here's the result:
>
> ~$ ./foreach
ron wrote:
> So I'm starting to work my way through Alan's online
> book, reading, then typing in code and seeing it work.
> The following is a snippet of code in the Loops
> section. I'm getting an error message.
>
> Here's the code and error message:
>
> myList = [1,2,3,4]
> for index in range(
ron wrote:
> Here's the code and error message:
>
Where?
Is it *gasp* invisdible?
>
>
>
>
>
> Be a PS3 game guru.
> Get your game face on with the latest PS3 news and previews at Yahoo! Games.
> http://videoga
1 - 100 of 104 matches
Mail list logo