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


Groups > comp.lang.python > #36496

Re: new to python and programming at large

References <0CF6C67958A245C883EB705CEF9F968F@favour>
Date 2013-01-10 02:18 +1100
Subject Re: new to python and programming at large
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.319.1357744700.2939.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

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

csiph-web