Newbie questions

Alex cut_me_out at hotmail.com
Tue Jun 13 08:48:48 EDT 2000


> pi = 3.141592654
> radius = input("Enter is the radius: ")
> circ = 2 * pi * radius
> print circ

Perhaps the third line should be 'circ = 2 * pi * float (radius)'

As it is, you are multiplying a float by a string, I think.  That should
be giving you a type error.

By the way, you can get pi from the math module:
import math
print math.pi

It's good not to have constants encoded directly in to your program, in
case they ever change. :)

Alex.



More information about the Python-list mailing list