0
Python 3 vs Python 2
In python3, why is int(1+2-3*4/5%6) zero whereas in python2 the same evalutes to 1 by substituting for '/' with'//'?
1 Odpowiedź
+ 8
Python2 used to return integer values when two integers were divided using "/". So 3/2 would mean 1, not 1.5
In Python3 it was effectively changed (changes were done gradually still in Python2 since 2.2) by introducing "//" as floor division operator. This made the division result more predictable and code-dependent.
You can read more on the background of this:
https://docs.python.org/3/whatsnew/2.2.html#pep-238-changing-the-division-operator