Total Python Noob

T

Tom Lake

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

What am I doing wrong?

Tom Lake
 
C

Chris Rebert

I have Python 2.6 installed on Vista Ultimate. When I try to calculate
sqrt (or any transcendental functions) I get the following error


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

Cheers,
Chris
 
S

shstein2002

I have Python 2.6 installed on Vista Ultimate.  When I try to calculate
sqrt (or any transcendental functions) I get the following error


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'
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top