Monday, June 16, 2008

Integer division in Python 3.0

>python
Python 2.5.1 (r251:54863, Feb  4 2008, 21:48:13) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 200/400
0
>>> 200.0/400
0.5
>>> from __future__ import division
>>> 200/400
0.5
>>> 200//400
0
>>> print "In Python 3.0 200/400 will yield 0.5"
In Python 3.0 200/400 will yield 0.5
>>>