The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

Why it showing error In[18]?(Converting float)

Why it showing error In[18]?(Converting float)

0
Votes
1
Answer

Create a variable equal to 99.

In [15]: x2 = 99

 

Check its type.
In [5]: type(99)

Out[5]:

int

Check the type of the value 0.99.

In [6]: type(0.99)

 
Out[6]: float

 
Turn 99 into a float.

In [18]: float(99)

 

 

—————————————————————————

TypeError                                 Traceback (most recent call last)
<ipython-input-18-0e339d82228c> in <module>
----> 1 float(99)

TypeError: 'int' object is not callable

 

– I am trying to convert 99 into float but it showing error. I am trying another way which is float(x2), but still it showing error.
Kindly help me out of this.

1 Answer

365 Team

Hi Raj!
Thanks for reaching out!
Your code is per se correct. Therefore, what may be causing the issue is if at some point, previously in your notebook document, you have created a variable float containing an integer value. For example, you may have executed the following:

float = 99

If you’ve really done this, this means when executing float(99), Python is trying to call float and it doesn’t know what to do with the parentheses and the number between them afterwards.
To solve this problem, please restart your kernel (which you can do by selecting Kernel/Restart & Clear Output  => Restart and Clear All Outputs), and retry running your code without assigning an integer (or any other value) to a variable called float.
Hope this helps.
Best,
Martin

Yeah, you are right after restating the kernel now it’s convert.Thank You Martin.

7 months

Great! You are welcome!

7 months