Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36496 > unrolled thread

Re: new to python and programming at large

Started byChris Angelico <rosuav@gmail.com>
First post2013-01-10 02:18 +1100
Last post2013-01-10 02:43 +1100
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: new to python and programming at large Chris Angelico <rosuav@gmail.com> - 2013-01-10 02:18 +1100
    Re: new to python and programming at large Alister <alister.ware@ntlworld.com> - 2013-01-09 15:38 +0000
      Re: new to python and programming at large Chris Angelico <rosuav@gmail.com> - 2013-01-10 02:43 +1100

#36496 — Re: new to python and programming at large

FromChris Angelico <rosuav@gmail.com>
Date2013-01-10 02:18 +1100
SubjectRe: new to python and programming at large
Message-ID<mailman.319.1357744700.2939.python-list@python.org>
On Thu, Jan 10, 2013 at 8:03 AM,  <kwakukwatiah@gmail.com> wrote:
> pls  I want to write a function that can compute for the sqrt root of any
> number.bt it not working pls help.
> from math import sqrt
> def squareroot(self):
>     x = sqrt(y)
>     print x

The 'self' argument is a convention used in classes. You probably want
to call your argument y:

def squareroot(y):

since that's what you then pass to math.sqrt.

Chris Angelico

[toc] | [next] | [standalone]


#36497

FromAlister <alister.ware@ntlworld.com>
Date2013-01-09 15:38 +0000
Message-ID<M9gHs.6$6N2.4@fx17.fr7>
In reply to#36496
On Thu, 10 Jan 2013 02:18:11 +1100, Chris Angelico wrote:

> On Thu, Jan 10, 2013 at 8:03 AM,  <kwakukwatiah@gmail.com> wrote:
>> pls  I want to write a function that can compute for the sqrt root of
>> any number.bt it not working pls help.
>> from math import sqrt def squareroot(self):
>>     x = sqrt(y)
>>     print x
> 
> The 'self' argument is a convention used in classes. You probably want
> to call your argument y:
> 
> def squareroot(y):
> 
> since that's what you then pass to math.sqrt.
> 
> Chris Angelico

why even do this when simply calling sqrt is all that is needed?




-- 
Outside of a dog, a book is man's best friend.  Inside of a dog, it is too
dark to read.

[toc] | [prev] | [next] | [standalone]


#36498

FromChris Angelico <rosuav@gmail.com>
Date2013-01-10 02:43 +1100
Message-ID<mailman.320.1357746205.2939.python-list@python.org>
In reply to#36497
On Thu, Jan 10, 2013 at 2:38 AM, Alister <alister.ware@ntlworld.com> wrote:
> On Thu, 10 Jan 2013 02:18:11 +1100, Chris Angelico wrote:
>
>> On Thu, Jan 10, 2013 at 8:03 AM,  <kwakukwatiah@gmail.com> wrote:
>>> pls  I want to write a function that can compute for the sqrt root of
>>> any number.bt it not working pls help.
>>> from math import sqrt def squareroot(self):
>>>     x = sqrt(y)
>>>     print x
>>
>> The 'self' argument is a convention used in classes. You probably want
>> to call your argument y:
>>
>> def squareroot(y):
>>
>> since that's what you then pass to math.sqrt.
>>
>> Chris Angelico
>
> why even do this when simply calling sqrt is all that is needed?

Good question. But without a lot more context from the OP, none of
this is really ponderable...

ChrisA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web