Nov-24-2016, 04:35 PM
The default behavior in Python 2 for integer division is to return an integer result that is floating point result. So 1/2 returns 0 instead of 0.5. This is known as "floor division".
There are a couple of fixes.
Convert one of the values to a float.
There are a couple of fixes.
Convert one of the values to a float.
>>> 81**(1.0/2) 9.0 >>>Python 3 changes the behavior of "/" to return a float. If changing to Python 3 is not practical, you can change the behavior of Python 2 to match Python 3 by using "from __future__ import division".
>>> from __future__ import division >>> 81**(1/2) 9.0