Re: [Tutor] Is there an easily or shorter way?

2014-12-15 Thread Dave Angel
On 12/15/2014 07:55 PM, Ken G. wrote: Oh, it is not an assignment, Dave. It is an actual program I am using for my benefit. I had to figure out on a fly, what is the name of a piece of property that each number represent. I had to reckon something out within a limited amount of time I had. Givin

Re: [Tutor] Is there an easily or shorter way?

2014-12-15 Thread Ken G.
On 12/15/2014 05:59 PM, Dave Angel wrote: On 12/15/2014 04:25 PM, Ken G. wrote: I am sure there is a better way to refine the following lines. Letting x equal a number from 1 to 28, go through 28 separate 'if' statements to print a resulting value that equaled the value of x. For example: x

Re: [Tutor] Is there an easily or shorter way?

2014-12-15 Thread Danny Yoo
> > Thank you but actually whatever number I get from either 1 to 28, > each number represent a property name such as "Reading Railroad", > "Judy Avenue", "Pacific Gas and Electric", etc., etc. > > For example: > > if x = 1 then print "Mediterranean Avenue" > if x = 2 then print "Baltic Avenue" A

Re: [Tutor] Is there an easily or shorter way?

2014-12-15 Thread Ken G.
On 12/15/2014 05:49 PM, Steven D'Aprano wrote: On Mon, Dec 15, 2014 at 04:25:42PM -0500, Ken G. wrote: I am sure there is a better way to refine the following lines. Letting x equal a number from 1 to 28, go through 28 separate 'if' statements to print a resulting value that equaled the value

Re: [Tutor] Is there an easily or shorter way?

2014-12-15 Thread Ken G.
On 12/15/2014 04:45 PM, Danny Yoo wrote: As a side note: if we were to talk about how we'd do this in a professional context, I think we'd recommend a library such as "humanize", which has functions to go from numbers to human-friendly string descriptions. https://pypi.python.org/pypi/huma

Re: [Tutor] Is there an easily or shorter way?

2014-12-15 Thread Steven D'Aprano
On Mon, Dec 15, 2014 at 06:04:17PM -0500, Dave Angel wrote: > On 12/15/2014 05:49 PM, Steven D'Aprano wrote: > > nine trillion, two hundred and seventy-four billion, > > eight hundred and ten million, two hundred and > > seventy-six thousand, five hundred and twenty-three > > That's u

Re: [Tutor] Is there an easily or shorter way?

2014-12-15 Thread Dave Angel
On 12/15/2014 05:49 PM, Steven D'Aprano wrote: On Mon, Dec 15, 2014 at 04:25:42PM -0500, Ken G. wrote: I am sure there is a better way to refine the following lines. Letting x equal a number from 1 to 28, go through 28 separate 'if' statements to print a resulting value that equaled the value o

Re: [Tutor] looking for a Python feature for computer teaching

2014-12-15 Thread Steven D'Aprano
On Mon, Dec 15, 2014 at 11:12:04AM +1100, Steven D'Aprano wrote: > On Sun, Dec 14, 2014 at 11:29:08AM -0800, Pi Po wrote: > > > Want each interpreted line of code to introduce as a cells on > > a spreadsheet window each new variable (or array) with its initialized > > value, > > and show the updat

Re: [Tutor] Is there an easily or shorter way?

2014-12-15 Thread Dave Angel
On 12/15/2014 04:25 PM, Ken G. wrote: I am sure there is a better way to refine the following lines. Letting x equal a number from 1 to 28, go through 28 separate 'if' statements to print a resulting value that equaled the value of x. For example: x = 8 if x = 1, print 'one' if x = 2, print '

Re: [Tutor] Is there an easily or shorter way?

2014-12-15 Thread Steven D'Aprano
On Mon, Dec 15, 2014 at 04:25:42PM -0500, Ken G. wrote: > I am sure there is a better way to refine the following lines. > > Letting x equal a number from 1 to 28, go through 28 separate 'if' > statements to print a resulting value that equaled the value of x. Since you only care about the first

Re: [Tutor] Is there an easily or shorter way?

2014-12-15 Thread Bod Soutar
On 15 December 2014 at 21:25, Ken G. wrote: > I am sure there is a better way to refine the following lines. > > Letting x equal a number from 1 to 28, go through 28 separate 'if' > statements to print a resulting value that equaled the value of x. > > For example: > > x = 8 > > if x = 1, print 'o

Re: [Tutor] Is there an easily or shorter way?

2014-12-15 Thread Danny Yoo
> As a side note: if we were to talk about how we'd do this in a > professional context, I think we'd recommend a library such as > "humanize", which has functions to go from numbers to human-friendly > string descriptions. > > https://pypi.python.org/pypi/humanize Whoops: wrong library. Hum

Re: [Tutor] Is there an easily or shorter way?

2014-12-15 Thread Danny Yoo
On Mon, Dec 15, 2014 at 1:25 PM, Ken G. wrote: > I am sure there is a better way to refine the following lines. > > Letting x equal a number from 1 to 28, go through 28 separate 'if' > statements to print a resulting value that equaled the value of x. Yes, the repetitive nature of those statemen

[Tutor] Is there an easily or shorter way?

2014-12-15 Thread Ken G.
I am sure there is a better way to refine the following lines. Letting x equal a number from 1 to 28, go through 28 separate 'if' statements to print a resulting value that equaled the value of x. For example: x = 8 if x = 1, print 'one' if x = 2, print 'two' ... ... if x = 8, print 'eight' ..

Re: [Tutor] about multiprocessing performance

2014-12-15 Thread Luis San Martin
I made a silly mistake as Jerry points its working above the same performance. Kind regards On Fri, Dec 12, 2014 at 8:27 PM, Alan Gauld wrote: > On 12/12/14 14:20, Luis San Martin wrote: >> >> Dear fellows, >> >> I'm learning about on multiprocessing module on python. So far I've >> enjoyed >> i

Re: [Tutor] looking for a Python feature for computer teaching

2014-12-15 Thread Danny Yoo
On Dec 14, 2014 3:35 PM, "Pi Po" wrote: > > As a teacher I find python simple and effective. > > However, appreciate feedback from anyone who knows > of a Python version with this feature: > > Want each interpreted line of code to introduce as a cells on > a spreadsheet window each new variable (o