Programming Tutorial for absolute beginners

Clodoaldo Pinto clodoaldo.pinto at gmail.com
Sun Apr 9 08:22:33 EDT 2006


Frank Millman wrote:
>
> We know that Python is in the process of changing the division
> operator. The main reason for the change is that the current approach
> is not intuitive to a newcomer (whether experienced or not).
>
> Why not think to the future, and do it like this. Instruct the reader
> to enter 'from __future__ import division'. You do not have to explain
> the details, just say that this is the way division will work in the
> future, and this statement will eventually not be required.
>
> Then your example will show that 3/2 = 1.5, which is what they would
> expect.
>
> Then you can mention that, if they just want the integer portion, they
> can use int(3/2). I think that most people with the slightest
> understanding of basic arithmetic will relate to this without a
> problem.
>
I included your suggestion in the forum topic that is linked from the
division paragraph:
http://programming-crash-course.com/integer_versus_float_division




More information about the Python-list mailing list