[Tutor] floats acting like integers??? (original) (raw)

Alan Gauld alan.gauld at blueyonder.co.uk
Tue Jul 27 23:34:42 CEST 2004


hello, I have a problem with my IDLE or script. I put in something like a=1/7 and I print a and get zero?

You are seeing integer division.

One divided by seven is zero with one seventh "left over"

If either number is a float you will get float division.

Or you can import from future the new style division...

There is a brief explanation of this in the simple sequences topic of my tutor.

Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld/tutor2/



More information about the Tutor mailing list