One point:
class Statistics:
def __init__(self, *value_list):
self.value = value_list
self.square_list= []
def mean(self, *value_list):
try :
ave = sum(self.value) / len(self.value)
except ZeroDivisionError:
ave = 0
return ave
You don't use value_list here you use self.value. So you don't need
James Reynolds wrote:
Thank you! I think I have working in the right direction. I have one more
question related to this module.
I had to move everything to a single module, but what I would like to do is
have this class in a file by itself so I can call this from other modules.
when it was in
On 25 February 2010 11:22, Dave Angel da...@ieee.org wrote:
The indentation in your code is lost when I look for it -- everything's
butted up against the left margin except for a single space before def
variance. This makes it very hard to follow, so I've ignored the thread
till now. This
-Original Message- From: Walter Prins <wpr...@gmail.com>Sent: Feb 25, 2010 7:09 AM To: Dave Angel <da...@ieee.org>Cc: Alan Gauld <alan.ga...@btinternet.com>, tutor@python.org Subject: Re: [Tutor] Strange list behaviour in classes
On 25 February 2010 11:22, Dave An
James Reynolds eire1...@gmail.com wrote
This thread inspired me to start learning object oriented as well, but it
seems I must be missing something fundamental.
No, this has nothing to do with objects, its just a broken algorithm.
median = Statistics.stats.median(*a)
n =
Forwarding to the list.
Please alweays use Reply All so others can comment too.
I made a few changes, but I'm getting the same error on variance (see below):
Looks like a different error to me!
It would seem to me that it should never evaluate if the denominator is zero
because of the if
Thanks for the reply.
I understand, but if self.value is any number other then 0, then the for
will append to the square list, in which case square_list will always have
some len greater than 0 when value is greater than 0?
I'm just trying to understand the mechanics. I'm assuming that isn't the
James Reynolds eire1...@gmail.com wrote
I understand, but if self.value is any number other then 0, then the
for
will append to the square list, in which case square_list will always
have
some len greater than 0 when value is greater than 0?
And if value does equal zero?
Actually I'm
Thank you! I think I have working in the right direction. I have one more
question related to this module.
I had to move everything to a single module, but what I would like to do is
have this class in a file by itself so I can call this from other modules.
when it was in separate modules it ran
On 02/24/10 10:27, C M Caine wrote:
Thanks all (again). I've read the classes tutorial in its entirety
now, the problem I had didn't seem to have been mentioned at any point
explicitly. I'm still a fairly inexperienced programmer, however, so
maybe I missed something in there or maybe this is
This thread inspired me to start learning object oriented as well, but it
seems I must be missing something fundamental. If I could get
an explanation of why I am raising the following exception, I would
greatly appreciate it.
I'm getting:
Traceback (most recent call last):
File
Or possibly strange list of object behaviour
IDLE 2.6.2
class Player():
hand = []
Colin = Player()
Alex = Player()
Players = [Colin, Alex]
def hands():
for player in Players:
player.hand.append(A)
hands()
Colin.hand
['A', 'A']
Alex.hand
['A',
On Mon, Feb 22, 2010 at 4:10 PM, C M Caine cmca...@googlemail.com wrote:
Or possibly strange list of object behaviour
IDLE 2.6.2
class Player():
hand = []
Colin = Player()
Alex = Player()
Players = [Colin, Alex]
def hands():
for player in Players:
On 23 February 2010 08:16, Benno Lang transmogribe...@gmail.com wrote:
class Hand:
def __init__(self):
self.hand = []
Of course, I meant class Player
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
On 23 February 2010 07:10, C M Caine cmca...@googlemail.com wrote:
Or possibly strange list of object behaviour
IDLE 2.6.2
class Player():
hand = []
Colin = Player()
Alex = Player()
Players = [Colin, Alex]
def hands():
for player in Players:
15 matches
Mail list logo