[Tutor] Division doesn't work
Geoframer
geoframer at gmail.com
Thu Jan 18 13:09:48 CET 2007
You assign s as an integer... it should be a float to get the right
result...
So either define s as
s = 14105.0
or as
s = float(14105)
it'll then result in the right answer :
In [17]: s=14105.0
In [18]: s/1024
Out[18]: 13.7744140625
In [19]: s = float(14105)
In [20]: s/1024
Out[20]: 13.7744140625
HTH - Geofram
On 1/18/07, Johan Geldenhuys <johan at accesstel.co.za> wrote:
>
> Hi all,
>
> In my script I want to convert 14105 bytes to kilobytes and and this is
> what I do:
>
> >>> s = 14105
> >>> print '%0.2f' % (s/1024)
> 13.00
>
> This not correct and I don't know why. The answer is 13.77.
>
> Any pointers please that would help my in the right direction?
>
> Thanks
>
> Johan
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.432 / Virus Database: 268.16.13/632 - Release Date:
> 2007/01/16 04:36 PM
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070118/313ad464/attachment.html
More information about the Tutor
mailing list