Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Python Newb :) 1

Status
Not open for further replies.

etones

Programmer
Mar 7, 2002
9
0
0
GB
HI all, started to learn python for a uni course im doing, im already a seasoned programmer, i find python in comparision to be.. well, annoying and crappy :)

Anyhow, im waiting for a few books I ordered to arrive, until then, im trying to use the math sqrt function on a float value, on running the program i get the error:

Traceback (innermost last):
File "sqrt.py", line 22, in ?
print sqrt(number)
NameError: sqrt

Now, do I have to somehow install a math module? If so how? Cheers,
Taz
 
Yes... you need to import the math module (RTFM).

>>> import math
>>> print math.sqrt(5)
2.2360679775
>>>

or you can do:

>>> from math import *
>>> print sqrt(5)
2.2360679775
>>>



Python isn't annoying and crappy :)
It's just that you're not used to it.
I would suggest a few good tutorials:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top