TypeError: 'float' object is not callable

Viewed 349958

I am trying to use values from an array in the following equation:

for x in range(len(prof)):
    PB = 2.25 * (1 - math.pow(math.e, (-3.7(prof[x])/2.25))) * (math.e, (0/2.25)))

When I run I receive the following error:

Traceback (most recent call last):
  File "C:/Users/cwpapine/Desktop/1mPro_Chlavg", line 240, in <module>
    PB = float(2.25 * (1 - math.pow(math.e, (-3.7(prof[x])/2.25))) * (math.e, (0/2.25)))
TypeError: 'float' object is not callable

this is probably something simple but I can't quite figure it out. Any help would be greatly appreciated. Thanks in advance

5 Answers

While this may not be an answer to this question in particular, another reason you could get this error is if you have defined "range" as a variable.

range = 0
for x in range(len(array)): 
#will give an error, because it's trying to multiply "range" with "(len(array))"

The solution would be to rename your variable to a synonym (period) or append something to it (range1, range_a)

The question has been answered but for others, the reason for the same error might be highly possible due to the following reason: Sometimes, when you use a variable name same as one of the inbuilt functions and when you try to call that inbuilt function later on, its gonna give you a type error. For example, somewhere in your code you define a variable as:

sum = 0

Maybe to use it as an accumulator variable in global dataframe. Now, later when you're defining a function in which you want to call the inbuilt function sum() , its gonna give an type error as you have over-written an in-built function name. That's why, you should avoid the use in-built function names like str, range, sum, etc.. as one of the variable names in your code.

Related