[Tutor] repply
hi I got it right. z=[] for x in range(1000): if divmod(x,3)[1]==0:z.append(x) if divmod(x,5)[1]==0:z.append(x) sum(set(z)) 233168 I am sorry if this is outside the perimeter of this list. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] repply
On Sun, Jan 4, 2009 at 14:18, prasad rao prasadarao...@gmail.com wrote: z=[] for x in range(1000): if divmod(x,3)[1]==0:z.append(x) if divmod(x,5)[1]==0:z.append(x) sum(set(z)) 233168 This can be done in one line of python. sum([x for x in range(1000) if x %3 == 0 or x % 5 == 0]) 233168 Greets Sander ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Repply
prasad rao prasadarao...@gmail.com wrote http://svn.python.org/view/python/trunk/Objects/listobject.c?rev=67498view=markup Kent ! This is grek and latin to me.From the presence of header files it looks C++.But headerfiles are not between '' and '' . Its C rather than C++. The in include statements are a variation on the which can also be used. The differences are subtle and have to do with the search path I think. But its been so long since I did serious C/++ I can't recall exactly! Alan Gauld! Basic exercises in C++ are to find min , malimum and sorting.So I am just trying it in python. Thats OK, I just wondered if you had some special algorithm you needed to use or something. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Repply
On Sat, Dec 27, 2008 at 3:42 AM, Alan Gauld alan.ga...@btinternet.comwrote: Its C rather than C++. The in include statements are a variation on the which can also be used. The differences are subtle and have to do with the search path I think. But its been so long since I did serious C/++ I can't recall exactly! It's only been about 2 weeks since I've been in class so that's a topic on which I can expound. searches the current directory before searching in the default library. It's pretty similar to the python import behavior, AFAICT. And now you know -Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Repply
Thanks for help. http://svn.python.org/view/python/trunk/Objects/listobject.c?rev=67498view=markup Kent ! This is grek and latin to me.From the presence of header files it looks C++.But headerfiles are not between '' and '' . But why are you trying to sort in this fashion? Alan Gauld! Basic exercises in C++ are to find min , malimum and sorting.So I am just trying it in python. Thank you Mark. Prasad ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor