Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > new to python and programming at large.

Reply
Thread Tools

new to python and programming at large.

 
 
John Gordon
Guest
Posts: n/a
 
      01-09-2013
In <mailman.328.1357750432.2939.python-> 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
B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

 
Reply With Quote
 
 
 
 
kwakukwatiah@gmail.com
Guest
Posts: n/a
 
      01-09-2013
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
new to python and programming at large kwakukwatiah@gmail.com Python 0 01-09-2013 09:03 PM
new to python and programming at large kwakukwatiah@gmail.com Python 1 01-09-2013 04:06 PM
Re: new to python and programming at large Chris Angelico Python 1 01-09-2013 03:43 PM
New to programming AND new to Ruby Cassandra K. Ruby 10 02-04-2011 08:07 PM
Can Your Programming Language Do This? Joel on functional programming and briefly on anonymous functions! Casey Hawthorne Python 4 08-04-2006 05:23 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57