Total Python Noob

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tom Lake

    Total Python Noob

    I have Python 2.6 installed on Vista Ultimate. When I try to calculate
    sqrt (or any transcendental functions) I get the following error
    >>sqrt(2)
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'sqrt' is not defined

    What am I doing wrong?

    Tom Lake
  • shstein2002@yahoo.com

    #2
    Re: Total Python Noob

    On Oct 9, 11:22 pm, "Tom Lake" <tl...@twcny.rr .comwrote:
    I have Python 2.6 installed on Vista Ultimate.  When I try to calculate
    sqrt (or any transcendental functions) I get the following error
    >
    >sqrt(2)
    >
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    NameError: name 'sqrt' is not defined
    >
    What am I doing wrong?
    >
    Tom Lake
    do 'from math import sqrt' first

    or try '2**0.5'

    Comment

    • Chris Rebert

      #3
      Re: Total Python Noob

      On Thu, Oct 9, 2008 at 11:22 PM, Tom Lake <tlake@twcny.rr .comwrote:
      I have Python 2.6 installed on Vista Ultimate. When I try to calculate
      sqrt (or any transcendental functions) I get the following error
      >
      >>>sqrt(2)
      >
      Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      NameError: name 'sqrt' is not defined
      >
      What am I doing wrong?
      They're not buitltin, they're in the 'math' module
      (http://docs.python.org/library/math.html#module-math), which you need
      to import.
      e.g.
      import math
      print math.sqrt(4)

      Please also Read the Fine Tutorial at:
      Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax an...


      Cheers,
      Chris
      --
      Follow the path of the Iguana...

      Comment

      • Tom Lake

        #4
        Re: Total Python Noob

        "Chris Rebert" <clp@rebertia.c omwrote in message
        news:mailman.23 04.1223620458.3 487.python-list@python.org ...
        On Thu, Oct 9, 2008 at 11:22 PM, Tom Lake <tlake@twcny.rr .comwrote:
        >I have Python 2.6 installed on Vista Ultimate. When I try to calculate
        >sqrt (or any transcendental functions) I get the following error
        >>
        >>>>sqrt(2)
        >>
        >Traceback (most recent call last):
        > File "<stdin>", line 1, in <module>
        >NameError: name 'sqrt' is not defined
        >>
        >What am I doing wrong?
        >
        They're not buitltin, they're in the 'math' module
        (http://docs.python.org/library/math.html#module-math), which you need
        to import.
        e.g.
        import math
        print math.sqrt(4)
        >
        Please also Read the Fine Tutorial at:
        http://docs.python.org/tutorial/index.html
        Great! Thanks so much!

        Tom Lake

        Comment

        Working...