Last answered:

04 Apr 2020

Posted on:

03 Apr 2020

0

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

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 answers ( 0 marked as helpful)
Instructor
Posted on:

04 Apr 2020

1
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

Submit an answer