• Register
1 vote
312 views

Problem:

I am begginer in python programming language and I am doing a course in it. I was doing some code to practice python programing. I wrote this code while doing my practice

from __future__ import division

x = 6.86
y = 9.79
z = 3.03

round((x/y)*0.88*z)

But it shows an error message 

Traceback (most recent call last):
TypeError: 'float' object is not callable

Is there any problem in my code. I am using python 2.7 as my default python version . I am new so please help me.

10 7 2
6,060 points

Please log in or register to answer this question.

2 Answers

1 vote

Answer:

"TypeError 'float' object is not callable" It probably means that you are trying to call a method when a property with the same name is available. If this is indeed the problem, the solution is easy. Simply change the method call into a property access.

In your case you may change the things

return <variable>

with

return str(<variable>)


So you should program like

from __future__ import division

x = 6.86
y = 9.79
z = 3.03

str(round((x/y)*0.88*z))

Happy coding.

11 6 4
34,950 points
0 votes

When working with different functions, then there may be a situation when a function is not properly called or invoked. You can face an error like;

“TypeError: ‘float’ object is not callable”.

This may be due to calling a float variable or object that is not callable.

Reason:

This may be due to syntax error or incorrect function definition.

What this error try to tell us?

This error is trying to tell us that the function you are trying to call is not a function object anymore. It is a different object and that object is not callable.

How to fix this error:

We can look for a variable that shares the same name as the function name and change the name to something else.

However, there are some cases when you cannot find the variable name. For example, In a juypter notebook, if you define a variable, it stays defined until you start kernel again and delete that variable. So there are chances that you define a variable named float and removed it from your code. However since it is not removed from the global scope, then you will keep getting the error.

How to delete a global scope variable?

A quick way to delete the global scope variable is to put del keyword at the start of variable definition.

In your case you can change program like;

from __future__ import division

 x = 6.86

 y = 9.79

 z = 3.03

 str(round((x/y)*0.88*z))

 

11 5 2
3,890 points

Related questions

2 votes
1 answer 67 views
67 views
Problem: What is TypeError: 'list' object is not callable error in python programming? Why does it happen? I was trying to working with a list in python. Suddenly, I got this error while I was trying run this below code list = [1, 2, 3] myrange = list(range(1, 10)) for num in list: if num in myrange: print(num, 'is between 1 and 10') Could any of you please shed some light on this?
asked Apr 7, 2020 Gavin 15.3k points
1 vote
1 answer 69 views
69 views
Problem: I am very noob in python programming language. To develope my skills I have been doing some coding prcatice. So, I wrote some which gives me error. The code I wrote is: for_test = "hiihihiiiiihhhi" print("The string you give is : " + str(for_test)) res = ... ')('%temp%', 'i') TypeError: 'str' object is not callable Why this error message is appearing can anyone explain.Please help me out.
asked Apr 7, 2020 LizzyM 6.1k points
1 vote
1 answer 50 views
50 views
Problem: I have a python project located at C:\Users\ASUS\Documents\OPO\aoi.py But when I try to run this project: C:\Users\ASUS\Documents\OPO\aoi.py, line 55, in __init__ self.serv = socket(AF_INET,SOCK_STREAM) TypeError: 'module' object is not callable Why am I getting this type of error message. Can anyone explain me this thing.
asked Apr 4, 2020 LizzyM 6.1k points
1 vote
1 answer 44 views
44 views
Problem: I am begginer in python programming language and I am doing a course in it. I was doing some code to practice python programing. I wrote this code while doing my practice from __future__ import division x = 66 y = 99 z = 33 round((x/y)*0.8*z) But it shows an ... not callable Is there any problem in my code. I am using python 2.7 as my default python version . I am new so please help me.
asked Apr 4, 2020 LizzyM 6.1k points
0 votes
1 answer 1 view
1 view
Problem: How to I Solve this : python typeerror: 'str' object is not callable HELP! I need help understanding this: python typeerror: 'str' object is not callable Can someone please help solve this, I am new in python().
asked 1 day ago Mashhoodch 10.2k points
2 votes
1 answer 48 views
48 views
Problem: I am a python newbee. I was trying some code : x = int(input("Input an Integer:")) res = [x] while x != 1: ---> for i in range(2, a): if x % i == 0: res.append(i) x = x / i break print(res) but this code shows some error ... did not compile. The error message is : TypeError: 'float' object cannot be interpreted as an integer Can any one tell me why am I getting this kind of error message?
asked Mar 23, 2020 LizzyM 6.1k points
0 votes
1 answer 1 view
1 view
Problem: How to I Solve this: python typeerror: 'nonetype' object is not iterable HELP! I need help understanding this: python typeerror: 'nonetype' object is not iterable Can someone please help solve this, I am new in python(). Someone have idea to solve this thanks!
asked 1 hour ago Mashhoodch 10.2k points
0 votes
1 answer 6 views
6 views
Problem: I am looking to make a loop so that for each element in the list, it will get broken down into each of it's characters. For example, say the number 137 was in the list then it would be turned into [1,3,7]. Then I want to add these numbers together (I ... it). However, I keep getting the error message TypeError: 'int' object is not iterable when I try and run this. What am I doing wrong?
asked Feb 23 Mashhoodch 10.2k points
0 votes
1 answer 17 views
17 views
Problem: I&rsquo;m working on the count problem, and have come up with the following code: def count(sequence, item): found = 0 for i in len(sequence): if sequence[i] == item: found = found + 1 return found
asked Jan 22 Mashhoodch 10.2k points
0 votes
1 answer 31 views
31 views
On making a small program for math there returned an error "TypeError: 'NoneType' object is not subscriptable. Never before has been seen, this error, so no idea what it means. import math print("The format you should consider:") print str("value 1a")+str(" + ")+ ... /Nathan/Documents/Python/New thing", line 16, in <module> a = lista[1] - lista[0] TypeError: 'NoneType' object is not subscriptable
asked Oct 24, 2020 psandprop 2.4k points