Hello -
I am very new to Python, and I am trying to write a program that returns the Area and Volume of a sphere when the user inputs the radius. I thought I had a solid program while typing it up:
But when I try to run the program, I recieve this error message:
Traceback (most recent call last):
File "<pyshell#0 >", line 1, in -toplevel-
sphere()
NameError: name 'sphere' is not defined
Upon further instpection, when I try to run the chaos.py program (taken directly from Zelle's "Python Programming: An Introduction to Computer Science"):
I get this error again:
Traceback (most recent call last):
File "<pyshell#0 >", line 1, in ?
main()
NameError: name 'main' is not defined
Any suggestions would be much appreciated.
I'm using 2.4.4 on Windows Vista.
Thanks!
I am very new to Python, and I am trying to write a program that returns the Area and Volume of a sphere when the user inputs the radius. I thought I had a solid program while typing it up:
Code:
import math
def sphere():
Radius = input("Please enter the radius of the sphere and press Enter: ")
Volume = (4/3*math.pi*Radius**3)
Area = (4*math.pi*Radius**2)
Print Volume
Print Area
sphere()
Traceback (most recent call last):
File "<pyshell#0 >", line 1, in -toplevel-
sphere()
NameError: name 'sphere' is not defined
Upon further instpection, when I try to run the chaos.py program (taken directly from Zelle's "Python Programming: An Introduction to Computer Science"):
Code:
def main():
print "This Program illustrates a chaotic function."
x = input("Enter a number between 0 and 1: ")
for i in range (10):
x = 3.9 * x * (1-x)
print x
main()
Traceback (most recent call last):
File "<pyshell#0 >", line 1, in ?
main()
NameError: name 'main' is not defined
Any suggestions would be much appreciated.
I'm using 2.4.4 on Windows Vista.
Thanks!
Comment