Programming Tutorial for absolute beginners

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Mon Apr 10 18:47:47 EDT 2006


In <1144572585.147756.144240 at i40g2000cwc.googlegroups.com>, Frank Millman
wrote:

> 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.

Or instead of converting the `float` back to an `int`, they can use
integer division:  ``3 // 2``

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list