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


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

new to python and programming at large.

Started bykwakukwatiah@gmail.com
First post2013-01-09 16:28 -0600
Last post2013-01-09 17:43 +0000
Articles 2 — 2 participants

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


Contents

  new to python and programming at large. kwakukwatiah@gmail.com - 2013-01-09 16:28 -0600
    Re: new to python and programming at large. John Gordon <gordon@panix.com> - 2013-01-09 17:43 +0000

#36508 — new to python and programming at large.

Fromkwakukwatiah@gmail.com
Date2013-01-09 16:28 -0600
Subjectnew to python and programming at large.
Message-ID<mailman.328.1357750432.2939.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

thanks for ur help I wz able to do it.but I wish to expand it by asking a user to input a number for the sqrt to be calculated it I dd it this way but its not working.


from math import sqrt
number = raw_input('enter a number:')
def number(y):
    return number(Y)


thnx

[toc] | [next] | [standalone]


#36512

FromJohn Gordon <gordon@panix.com>
Date2013-01-09 17:43 +0000
Message-ID<kcka8q$cod$1@reader1.panix.com>
In reply to#36508
In <mailman.328.1357750432.2939.python-list@python.org> kwakukwatiah@gmail.com writes:

> thanks for ur help I wz able to do it.but I wish to expand it by asking
> a user to input a number for the sqrt to be calculated it I dd it this
> way but its not working.

> from math import sqrt
> number = raw_input('enter a number:')
> def number(y):
>     return number(Y)

You're storing the user input in a variable called 'number', but then
you define a method also called 'number'.  Call them something different.

Within your method, you probably want to return sqrt(y) instead of calling
the method from itself.

The argument to your method is called 'y' in the definition, but you refer
to it as 'Y' in the return statement.  Variable names are case-sensitive.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

[toc] | [prev] | [standalone]


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


csiph-web