O'Reilly logo
  • Eihab Hala thinks this is interesting:

Also, notice that all the numbers are integers in the first expression. Because of that, Python 2.X’s / performs integer division and addition and will give a result of 5, whereas Python 3.X’s / performs true division, which always retains fractional remainders and gives the result 5.0 shown. If you want 2.X’s integer division in 3.X, code this as b // 2 + a; if you want 3.X’s true division in 2.X, code this as b / 2.0 + a (more on division in a moment).

From

Cover of Learning Python, 5th Edition

Note

Number Division