[Tutor] Tutorial indicating different output

Eric Morey eric at glodime.com
Thu May 8 22:38:49 CEST 2008


Hello everyone,

I have no prior experience with programing. I've just started with the
Python tutorial at http://www.dickbaldwin.com/tocpyth.htm. 
On the section that describes decimal division on this page:
http://www.dickbaldwin.com/python/Pyth0004.htm

Figure 10 shows:

        >>> 2.0/5 # get decimal quotient 
        0.4 
        >>> 2/5.0 # do it again 
        0.4 
        >>>

http://www.dickbaldwin.com/python/Pyth0004-fig10.htm


Howerver, using the python shell in my terminal, I get:
        >>> 2.0/5 # get decimal quotient
        0.40000000000000002
        >>> 2/5.0 # do it again 
        0.40000000000000002
        >>> 

I didn't worry too much about it and continued to move on. But I'm
curious as to why there was a difference. Anyone know why?

Eric...



More information about the Tutor mailing list