new to python and programming at large.

Discussion in 'Python' started by John Gordon, Jan 9, 2013.

  1. John Gordon

    John Gordon Guest

    In <> 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"
     
    John Gordon, Jan 9, 2013
    #1
    1. Advertisements

  2. John Gordon

    Guest

    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
     
    , Jan 9, 2013
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ketchup
    Replies:
    1
    Views:
    417
    Jan Tielens
    May 25, 2004
  2. Jon Kupe
    Replies:
    7
    Views:
    456
    Jon Kupe
    Sep 25, 2009
  3. Cassandra K.

    New to programming AND new to Ruby

    Cassandra K., Jan 31, 2011, in forum: Ruby
    Replies:
    10
    Views:
    493
    Clent Crumley
    Feb 4, 2011
  4. Replies:
    5
    Views:
    1,610
    Xho Jingleheimerschmidt
    Apr 2, 2009
  5. Replies:
    2
    Views:
    767
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
  6. Replies:
    0
    Views:
    219
  7. Ulrich Eckhardt

    new to python and programming at large

    Ulrich Eckhardt, Jan 9, 2013, in forum: Python
    Replies:
    1
    Views:
    224
  8. Chris Angelico

    Re: new to python and programming at large

    Chris Angelico, Jan 9, 2013, in forum: Python
    Replies:
    1
    Views:
    232
    Chris Angelico
    Jan 9, 2013
Loading...