3 ms·
In Python 2: > 20 / 15 = 1 > 20.0 / 15 = 1.3333333333333333 > 20 / 15. = 1.3333333333333333 > 20. / 15. = 1.3333333333333333 In Python 3: > X / Y is ALWAY
by loa_in_ 5y ago
In Python 2:
> 20 / 15 = 1
> 20.0 / 15 = 1.3333333333333333
> 20 / 15. = 1.3333333333333333
> 20. / 15. = 1.3333333333333333
In Python 3:
> X / Y is ALWAYS float division
> X // Y is ALWAYS integer division
This was managable in Python 2 but led to lots of float(argument) calls in every function that wanted to do float division. That lead to unnecessary calls, and unnecessary noise in the code.