Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'int' object is not callable error in python

I'm getting this error:

Traceback (most recent call last):
  File "C:\Users\George\Desktop\ex3.py", line 15, in <module>
    s=s+d*2(-1/6.)*(u-1)*(u-2)*(u+2)*(u-4)
TypeError: 'int' object is not callable

Here is my code:

x=input()
z=input()
n=input()
while x>=z:
    x=input()
    z=input()
while n<0:
    n=input()
while n>0:
    d=(z-x)/1.*n
    k=1
    s=(d/2.)*((-1/6.)*(x-1)*(x-2)*(x+2)*(x-4)+(-1/6.)*(z-1)*(z-2)*(z+2)*(z-4))
    while k<=n-1:
        u=x+k*d
        s=s+d*2(-1/6.)*(u-1)*(u-2)*(u+2)*(u-4)
        k=k+1
        print "%.3f" %s
        x=input()
        z=input()
        n=input()
        if n>0:
            while x>=z:
                x=input()
                z=input()
like image 451
GeorgeDavidKing Avatar asked Nov 22 '13 18:11

GeorgeDavidKing


People also ask

How do I fix error module object is not callable?

How to fix typeerror: 'module' object is not callable? To fix this error, we need to change the import statement in “mycode.py” file and specify a specific function in our import statement.

What is callable error in Python?

That error occurs when you try to call, with () , an object that is not callable. A callable object can be a function or a class (that implements __call__ method). According to Python Docs: object.__call__(self[, args... ]): Called when the instance is “called” as a function.

What is int object in Python?

Python int() The int() method converts any string, bytes-like object or a number to integer and returns.

Do integer values have callable methods Python?

The Python "TypeError: 'int' object is not callable" occurs when we try to call an integer value as a function. To solve the error, correct the assignment, make sure not to override the built-in int() function, and resolve any clashes between function and variable names.


1 Answers

You are trying to use 2 as a function:

2(-1/6.)

Insert a * to multiply:

2*(-1/6.)

or as a full expression:

s=s+d*2*(-1/6.)*(u-1)*(u-2)*(u+2)*(u-4)
like image 59
Martijn Pieters Avatar answered Oct 25 '22 21:10

Martijn Pieters