Division in Python 2 vs 3

One major change in Python 3 is the implementation of the division operator /.

In Python 2 the division yielded a floor rounded integer when dividing two integers but a float when using a float as divider or divisor. Due to Python’s weakly typed nature this behavior could lead to some issues. So PEP-238 changed the behavior of the operator in Python 3 and introduced a new operator // in Python 2.2. Let’s have a look at the different behavior [table id=5 /]

If You want to use the new behavior of operator / from Python 3 in Python 2 you can do:

from __future__ import division

So have fun when You divide and conquer 🙂