Byte wrote:
> How come:
>
> sum = 1/4
> print sum
>
> returns 0? 1/4=0.25, not 0. How do I fix this?

Make sure there is at least one float in your equation. In your example
Python is doing interger math for you and returing the floor. You need
to give it a hint that you would like to do floating point math.

>>> sum = 1.0/4
>>> print sum
0.25
>>> sum = 1/4.0
>>> print sum
0.25
>>>

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to