[Tutor] float object not callable error
Kristinn Didriksson
kdidriksson at gmail.com
Thu Oct 12 20:05:41 CEST 2006
Hello,
I an completely new to programming and am trying to teach myself
Python using Python Programming by John Zelle. Essentially I am an ex-
tech writer trying to learn how to program.
My system: Mac OS X 10.4, Python 2.5, TextMate editor
Here is the problem:
I get 'float' object not callable error.
I thought this was a conversion error, but it seems to me that it may
be something else. It will not print x and I don't understand why it
will not do that. Any help is greatly appreciated.
This is the code below. When I got the error message initially, I
tried to break it down into smaller bites so I could see the problem
more clearly. I tried to figure this out myself, but not having any
luck.
Regards,
Kristinn
# Calculate the area of a triangle. Input the lengths of the sides:
a, b, c.
# Formulas: (s = a + b + c) / 2
# A = sqrt(s(s - a)(s -b)(s - c))
def main():
import math
a, b, c = input("Please enter the sides of the triangle separated by
commas: ")
s = (float(a + b + c)/2)
print s #This is to test the first part of the algorithm--and it fails
x = (s(s -a)(s -b)(s -c))
print x
y = math.sqrt(x)
print y
#area = math.sqrt((s)(s - a)(s -b)(s-c)) --this is the formula that
will not work
print "This is the area of the traingle: " + area
main()
# This algorithm has type conversion problems.
# Error message: 'float' object is not callable
More information about the Tutor
mailing list