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
> 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
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
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
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
> 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
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
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)
>
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:
Try this:
# The player tries to guess it and the computer lets
# the player know if the guess is too high, too low
# or right on the money
import random
print "\tWelcome to 'Guess My Number'!"
print "\nI'm thinking of a number between 1 and 100."
print "Try to guess it in as few attempts as pos
L PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of garywood
Sent: Thursday, August 07, 2008 1:56 PM
To: python-list@python.org
Subject: very newbie question
stuck on python for absolute beginners
chapter 6
i actually done what i was supposed to do use the function ask_number for guess
a number
bu
garywood wrote:
stuck on python for absolute beginners
chapter 6
i actually done what i was supposed to do use the function ask_number
for guess a number
but for some reason it does not count correctly the number of tries
# Guess My Number
#
# The computer picks a random number between 1 and
stuck on python for absolute beginners
chapter 6
i actually done what i was supposed to do use the function ask_number for guess
a number
but for some reason it does not count correctly the number of tries
# Guess My Number
#
# The computer picks a random number between 1 and 100
# The player
On Jul 7, 7:09 pm, Jeff <[EMAIL PROTECTED]> wrote:
> When you call c3.createJoe(c1.fred), you are passing a copy of the
> value stored in c1.fred to your function. Python passes function
> parameters by value.
No, python doesn't pass variable either by value or by reference. The
behavior in pytho
Jeff wrote:
When you call c3.createJoe(c1.fred), you are passing a copy of the
value stored in c1.fred to your function. Python passes function
parameters by value.
These statements are both wrong. Function argument objects or objects
derived therefrom are bound to function parameter names
On Jul 7, 5:07 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Mon, 7 Jul 2008 05:41:22 -0700 (PDT), mcl <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
>
> > My use of classes is because I want two classes one for global
> > variables and one for global functions.
>
>
Jerry Hill wrote:
> On Mon, Jul 7, 2008 at 7:30 AM, mcl <[EMAIL PROTECTED]> wrote:
>> I did not think you had to make the distinction between 'byvar' and
>> 'byref' as in Basic.
>
> Python does not use "call by value" or "call by reference" semantics.
> Instead, python's model is "call by object".
On Mon, 7 Jul 2008 05:41:22 -0700 (PDT), mcl <[EMAIL PROTECTED]> wrote:
[snip]
> My use of classes is because I want two classes one for global
> variables and one for global functions.
One of the many lovely things about programming in the
Python style is that very few things need to be global.
On Mon, Jul 7, 2008 at 7:30 AM, mcl <[EMAIL PROTECTED]> wrote:
> I did not think you had to make the distinction between 'byvar' and
> 'byref' as in Basic.
Python does not use "call by value" or "call by reference" semantics.
Instead, python's model is "call by object". See this writeup for
some
mcl wrote:
> On 7 Jul, 13:09, Jeff <[EMAIL PROTECTED]> wrote:
>> When you call c3.createJoe(c1.fred), you are passing a copy of the
>> value stored in c1.fred to your function. Python passes function
>> parameters by value. The function will not destructively modify its
>> arguments; you must exp
On 7 Jul, 13:09, Jeff <[EMAIL PROTECTED]> wrote:
> When you call c3.createJoe(c1.fred), you are passing a copy of the
> value stored in c1.fred to your function. Python passes function
> parameters by value. The function will not destructively modify its
> arguments; you must expliticly state you
When you call c3.createJoe(c1.fred), you are passing a copy of the
value stored in c1.fred to your function. Python passes function
parameters by value. The function will not destructively modify its
arguments; you must expliticly state your intention to modify an
object:
class one():
fred =
mcl wrote:
> Why can I not the change the value of a variable in another class,
> when I have passed it via a parameter list.
>
> I am sure I am being stupid, but I thought passed objects were Read/
> Write
In Python, there are names which are bound to objects. Doing "foo = bar"
and then "foo = s
Why can I not the change the value of a variable in another class,
when I have passed it via a parameter list.
I am sure I am being stupid, but I thought passed objects were Read/
Write
eg
#!/usr/bin/python
class one(): #my Global Var
In short input runs an eval on the text before it passes it! So input like
ord('a') will work fine because it will run that code!
On Dec 26, 2007 5:26 AM, <[EMAIL PROTECTED]> wrote:
> Thanks guys! It worked.
>
> Merry Christmas!
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Thanks guys! It worked.
Merry Christmas!
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> code sample:
> --
> i=input()
> try:
> x=int(i)
> print "you input an integer"
> except ValueError:
> print "you must input an integer"
>
> when I input a value like,
code sample:
--
i=input()
try:
x=int(i)
print "you input an integer"
except ValueError:
print "you must input an integer"
when I input a value like, b
I got the traceback message instead of prop
28 matches
Mail list logo