I have a simple script trying to calculate the area and circumference of a circle. On the first iteration of the loop, it works just fine. However, on the second it breaks saying "'float' object is not callable". Any ideas on what is wrong?
Error Message:
Traceback (most recent call last):
File "C:/Users/Administrator/Google Drive/School/Spring 2015/Scripting/ITD2313-Portfolio-GandyBrandon/Assignments/Hands-on & Labs/Question1.py", line 16, in <module>
area = area(radius)
TypeError: 'float' object is not callable
Code:
import math
finished = False
def area(number):
area = math.pi * (number**2)
return area
def circum(number):
c = 2 * math.pi * number
return c
while (finished == False):
radius = 0
radius = int(input("Please input the radius: "))
if radius <= 0:
print ("Exitting the program...")
finished = True
else:
area = area(radius)
circum = circum(radius)
print (area)
print (circum)
areaandcircum, and functions with the same name. Don't do that. Also, next time, please post the full text of the error or traceback, as it points directly to where the error is occurring.finishedis a boolean. You should not explicitly writewhile finished == False, you can just use the boolean itself, like this:while finishedorwhile ! finished.