-
How do I debug this code of the 'TypeError: 'int' object is not callable' error in Python?
almost 9 years ago
-
almost 9 years ago
Use this code and resolve your problem int object is not callable.
n = input('Give the value of n.')
n = int (n)
s = (((n+1))/2)**2
print ('Sum equals =', s) -
-
almost 8 years ago
n=raw_input("enter the valude of n")
n=int(n)
s = ((n*(n+1))/2)**2
print s
Just add a multiply sign there next to n and it will start working. (It doesnt work how we write on a paper ) -
-
over 8 years ago
This particular error aside, I think what you really want is:
sum( [i**3 for i in range(n+1)] )
-
-
over 8 years ago
when you get a error like that: "type integer is not callable", it's prabbly a syntax error / typo:
the syntax for calling a function in Python is to put parens after it:
fun()
so look and see if you have put parens after something that is not a function -- and indeed you have:
(note this UI sucks! I have to write this in a modal dialog, so I can't see the original question!)
I think you have code like:
n(1 + n)
look for the n(...) -- that is math notation for multiply, but it's python notation for call the function "n" -- it should be:
n * (1 + n)
-
-
almost 9 years ago
You have to redefined your "sum" function to be an integer data type. So it is rightly telling you that an integer is not something you can pass a range.To fix this, restart your interpreter.Then all is okay.like this n = input('Give the value of n.') n = int (n) s = (((n+1))/2)**2 print ('Sum equals =', s)
-
-
almost 9 years ago
use this and solve the type error : int object in not callable n = input('Give the value of n.') n = int (n) s = (((n+1))/2)**2 print ('Sum equals =', s)
-
-
almost 9 years ago
You have to redefined your "sum" function to be an integer data type. So it is rightly telling you that an integer is not something you can pass a range.To fix this, restart your interpreter.Then all is okay
-
7 Answer(s)