Why is 2/1 == 1.0 in Python3?
I was astonished by this result:
Python 3.8.5 (default, Aug 2 2020, 15:09:07)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 2/1
2.0
Why is that?
Why is that?
1.0 would surprise me, 2.0 is because, as others said, “/” was changed to do ‘normal’ division, with “//” a new operator for integer division (flooring the result)
Dates to PEP 238 from 2001: https://www.python.org/dev/peps/pep-0238/
>>> 2/1
2.0 >>> 2//1
2