A Callable Float? Fun and Creativity in Python

<p>Among the built-in data types in Python, we have a number of types representing numbers, the most important being&nbsp;<code>int</code>&nbsp;and&nbsp;<code>float</code>. As everything in Python, their instances are objects; and as objects, they have their own attributes and methods. For example, this is what instances of the&nbsp;<code>float</code>&nbsp;type offer:</p> <p>As you see,&nbsp;<code>float</code>&nbsp;numbers offer many different methods to use. What they do not offer is a&nbsp;<code>.__call__()</code>&nbsp;method, which means you cannot call them.</p> <p>Have you ever pondered why we cannot call a floating-point number the way you can call a function? Look:</p> <pre> &gt;&gt;&gt; i = 10.0012 &gt;&gt;&gt; i() Traceback (most recent call last): ... TypeError: &#39;float&#39; object is not callable</pre> <p>It does not work. And why does it not work?!</p> <p>To be honest&hellip; I&rsquo;ve never pondered why floats are not callable &mdash; but it makes perfect sense to me. Why would they? What for? Do you see any particular reason for them to be? I don&rsquo;t.</p> <p><a href="https://towardsdatascience.com/a-callable-float-fun-and-creativity-in-python-7a311ccd742d">Visit Now</a></p>