I am also using Zelle's book to teach myself programming and Python. I also had a problem with " import math ", but the alternative of " from math import * " is working for me. I don't know why one works and the other doesn't.
Cousin Stanley-3 wrote: > > >> >> Here is the arithmetic program I made that it worked before I added >> the "import math" line. >> >> #volumen.py >> # A program to compute the volume and surface area of a sphere >> import math >> >> .... >> NameError: global name 'pi' is not defined >> .... > >>>> from math import * >>>> >>>> def surface( r ) : > ... return 4 * pi * r ** 2 > ... >>>> def volume( r ) : > ... return ( 4. / 3. ) * pi * r ** 3 > ... >>>> for n in range( 1 , 11 ) : > ... s = surface( n ) > ... v = volume( n ) > ... print ' %2d .... %9.4f .... %9.4f ' % ( n , s , v ) > ... > > > -- > Stanley C. Kitching > Human Being > Phoenix, Arizona > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- View this message in context: http://www.nabble.com/Python-Math-libraries---How-to--tp16952032p17127534.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list