Newbie questions

Jim Richardson warlock at eskimo.com
Tue Jun 13 19:18:18 EDT 2000


On Mon, 12 Jun 2000 21:10:35 -0700, 
 jim roush, in the persona of <jar at mminternet.com>,
 brought forth the following words...:

>I'm just learning Python.  The following code does not work.  It's
>supposed to calculate the circumference after the user enters the
>radius.  The program displays the prompt, but when I enter the radius
>and the press enter, nothing happens.
>
>FYI, I'm using Python 1.5.2 on WinNT.
>
>pi = 3.141592654
>radius = input("Enter is the radius: ")
>circ = 2 * pi * radius
>print circ
>
>
I am just a newbie but the following code works for me (on linux, hence 
the #! first line)

#!/usr/bin/env  python
import string,math
#Import string for the atoi function, since raw_input returns a string
#Import math so pi has many digits :)

radius=string.atoi(raw_input('Radius? '))
circ = 2*math.pi*radius

print circ

#Or to print circ to only 2 places

print 'Circumference is %.2f'%circ
-- 
Jim Richardson
	Anarchist, pagan and proud of it
WWW.eskimo.com/~warlock
	Linux, because life's too short for a buggy OS.




More information about the Python-list mailing list