python only prints integers

Noah Hall enalicho at gmail.com
Thu Jan 6 18:02:59 EST 2011


On Thu, Jan 6, 2011 at 10:49 PM, francesco
<cerutti.francesco.to at gmail.com>wrote:

> I'm pretty new in Python language. I have a problem with numbers: it
> seems python doesn't know any more how to count!
> I get only the down rounded integer
> 20/8 = 2
> 8/3=2
> I probably changed some option to round the numbers, but I don't
> remember how.
> Is there a way to reset the number of digits to default?
> Thanks in advance
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Hi, the problem is that you've used two integers, which in turn return an
integer. In order to get around your problem, try 20.0/8 - the 20.0 is a
float, which will return a float. Have a read here -
http://docs.python.org/library/stdtypes.html#numeric-types-int-float-long-complex

Might I also suggest that you use the tutor at python.org mailing list for
beginner questions - you'll get more help there. :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110106/db453d9b/attachment.html>


More information about the Python-list mailing list