float object is not callable even I didn't use function name

Viewed 52
import math
i=0
arm_pop=float(0)
for i in range(1,16):
    arm_pop=round(1000000*math.e(3*i)/(10000+100(math.e((3*i)-1))))
    print(arm_pop)

<>:5: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?
<>:5: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?
C:\Users\pasto\AppData\Local\Temp/ipykernel_22396/4049563446.py:5: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?
  arm_pop=round(1000000*math.e(3*i)/(10000+100(math.e((3*i)-1))))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_22396/4049563446.py in <module>
      3 arm_pop=float(0)
      4 for i in range(1,16):
----> 5     arm_pop=round(1000000*math.e(3*i)/(10000+100(math.e((3*i)-1))))
      6     print(arm_pop)
      7 

TypeError: 'float' object is not callable

I didn't use function names, but the error comes out. How do I solve this error?

3 Answers

You forgot to add an operator after math.e, therefore, Python is interpreting it as a function call.

1000000*math.e(3*i)

Your code should be something like

1000000*math.e<your operator>(3*i) 
# concretely something like
1000000*math.e/(3*i) 

Or perhaps your were looking for an exponential function, with would be something like math.exp(value), which raises e to the given power(value parameter), as mentioned in the direct comments.

EDIT

You forgot several operators, please note that Python does not interpret 100x as 100*x - every mathematical operation must be written explicitly.

Here you've missed * sign math.e((3*i)

math.e is a float, not a function. Remember python isn't exactly written as math. you should do this:

import math
i=0
arm_pop=float(0)
for i in range(1,16):
    print(math.e)
    arm_pop=round(1000000*math.e*(3*i)/(10000+100*(math.e*((3*i)-1))))
    print(arm_pop)
Related