Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   new to python and programming at large. (http://www.velocityreviews.com/forums/t956356-new-to-python-and-programming-at-large.html)

John Gordon 01-09-2013 05:43 PM

Re: new to python and programming at large.
 
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"


kwakukwatiah@gmail.com 01-09-2013 10:28 PM

new to python and programming at large.
 
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


All times are GMT. The time now is 05:43 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.