Re: [Tutor] selecting data from a list

2015-01-17 Thread Peter Otten
Colin Ross wrote: > Hi all, > > I am attempting to isolate a certain subset of data from the list "a" and > then turn it into any array. To do so, I have written the following code: > > import numpy as np > > a = [0,1,2,3,4,5,6,7,8,9,10] > b = [10,20,30,40,50,60,70,80,90,100,110] > > for a in

Re: [Tutor] selecting data from a list

2015-01-17 Thread Alan Gauld
On 18/01/15 00:49, Colin Ross wrote: a = [0,1,2,3,4,5,6,7,8,9,10] b = [10,20,30,40,50,60,70,80,90,100,110] for a in range(len(a)): if a > 5: print a You have named your iteration cvariable the same as the list you are iterating over. Don't ever do this! In effect you have made y

Re: [Tutor] selecting data from a list

2015-01-17 Thread Steven D'Aprano
Hi Colin, and welcome. My responses are interleaved with your comments below. On Sat, Jan 17, 2015 at 08:49:30PM -0400, Colin Ross wrote: > Hi all, > > I am attempting to isolate a certain subset of data from the list "a" and > then turn it into any array. To do so, I have written the following

[Tutor] selecting data from a list

2015-01-17 Thread Colin Ross
Hi all, I am attempting to isolate a certain subset of data from the list "a" and then turn it into any array. To do so, I have written the following code: import numpy as np a = [0,1,2,3,4,5,6,7,8,9,10] b = [10,20,30,40,50,60,70,80,90,100,110] for a in range(len(a)): if a > 5: print a a_1 = n

Re: [Tutor] Timing a python program

2015-01-17 Thread Albert-Jan Roskam
- Original Message - > From: CL Talk > To: Danny Yoo > Cc: Python Tutor Mailing List > Sent: Saturday, January 17, 2015 4:04 AM > Subject: Re: [Tutor] Timing a python program > >T hanks to all the responses. I have started looking at the > documentation and will be implementing it.

Re: [Tutor] menu based programs

2015-01-17 Thread Alan Gauld
On 17/01/15 02:00, Alan Gauld wrote: Here is a very simple example modelled on your description # def readMenu(menu): while not (1<= choice <= len(menu) ): for index, item in enumerate(menu,start=1): print (index, item) choice = input("\nchoo

Re: [Tutor] Timing a python program

2015-01-17 Thread CL Talk
Thanks to all the responses. I have started looking at the documentation and will be implementing it. Thanks for the direction. I only have megabytes of data files. I think that the program can be optimized and am hoping that with the profiler I will be able to get some insight. Thanks again. On