Re: Newbie to python. Very newbie question

2013-04-07 Thread Steven D'Aprano
On Sun, 07 Apr 2013 04:16:27 -0700, ReviewBoard User wrote: > Hi > I am a newbie to python and am trying to write a program that does a sum > of squares of numbers whose squares are odd. For example, for x from 1 > to 100, it generates 165 as an output (sum of 1,9,25,49,81) > > Here is the code I

Re: Newbie to python. Very newbie question

2013-04-07 Thread Miki Tebeka
> I can't even read that mess... three nested lambda? I have to say this and other answers in this thread seem not that friendly to me. The OP said it's a newbie question, we should be more welcoming to newcomers. -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie to python. Very newbie question

2013-04-07 Thread Arnaud Delobelle
On 7 April 2013 20:23, Ian Foote wrote: > I'm surprised no one has suggested: > import math sum( x*x for x in range(1, int(math.sqrt(100)), 2)) Yeah! And I'm surprised no one came up with: >>> from itertools import count, takewhile >>> sum(takewhile((100).__gt__, filter((2).__rmod__, m

Re: Newbie to python. Very newbie question

2013-04-07 Thread Ian Foote
On 07/04/13 20:09, Dennis Lee Bieber wrote: On Sun, 7 Apr 2013 04:16:27 -0700 (PDT), ReviewBoard User declaimed the following in gmane.comp.python.general: Hi I am a newbie to python and am trying to write a program that does a sum of squares of numbers whose squares are odd. For example, for

Re: Newbie to python. Very newbie question

2013-04-07 Thread rusi
On Apr 7, 4:16 pm, ReviewBoard User wrote: > Hi > I am a newbie to python and am trying to write a program that does a > sum of squares of numbers whose squares are odd. > For example, for x from 1 to 100, it generates 165 as an output (sum > of 1,9,25,49,81) > > Here is the code I have > print re

Re: Newbie to python. Very newbie question

2013-04-07 Thread Miki Tebeka
> I am a newbie to python Welcome! I hope you'll do great things with Python. > and am trying to write a program that does a > sum of squares of numbers whose squares are odd. OK. > For example, for x from 1 to 100, it generates 165 as an output (sum > of 1,9,25,49,81) I don't follow, you seem to

Re: Newbie to python. Very newbie question

2013-04-07 Thread Dave Angel
On 04/07/2013 07:16 AM, ReviewBoard User wrote: Hi I am a newbie to python Then why are you trying to do 7 or 8 things on one line? and am trying to write a program that does a sum of squares of numbers whose squares are odd. For example, for x from 1 to 100, it generates 165 as an output (su

Re: Newbie to python. Very newbie question

2013-04-07 Thread Kruno Saho
On Sunday, April 7, 2013 9:16:27 PM UTC+10, ReviewBoard User wrote: > Hi > > I am a newbie to python and am trying to write a program that does a > > sum of squares of numbers whose squares are odd. > > For example, for x from 1 to 100, it generates 165 as an output (sum > > of 1,9,25,49,81) >

Newbie to python. Very newbie question

2013-04-07 Thread ReviewBoard User
Hi I am a newbie to python and am trying to write a program that does a sum of squares of numbers whose squares are odd. For example, for x from 1 to 100, it generates 165 as an output (sum of 1,9,25,49,81) Here is the code I have print reduce(lambda x, y: x+y, filter(lambda x: x%2, map(lambda x: