[Tutor] can't use floor or ceil functions in python

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Mon, 4 Mar 2002 16:07:55 -0800 (PST)


On Mon, 4 Mar 2002, Tom Horton wrote:

> I've downloaded and am practicing with Python 2.1.2 for Windows and am
> reading the book by Ivan Van Laningham titled Teach Yourself Python in
> 24 hours.

Cool; how is the book?


> I'm in the 3rd hour and can't seem to get the floor and ceil (or pi)
> functions to run.  It says these commands are not defined.  Any ideas?

Those functions and variables should be defined in the 'math' module, so
you may need to 'import' the math module before playing with it.  Here's
an example in the interactive interpreter:

###
>>> import math
>>> math.pi
3.1415926535897931
>>> math.ceil(math.pi)
4.0
>>> math.floor(math.pi)
3.0
###


By the way, your post may have been delayed for a few hours because you
aren't subscribed to Tutor yet; you can subscribe here:

    http://mail.python.org/mailman/listinfo/tutor

and your posts shouldn't get delayed after that.

(This requirement might seem stringent, but we've chosen to do moderation
on non-subscribers because spammers try abusing us every so often.)


If you have more questions, please feel free to ask them.  Best of wishes!