decimal numbers
Luke Geelen
luke.geelen at gmail.com
Sat Feb 15 05:32:39 EST 2014
Op zaterdag 15 februari 2014 11:04:17 UTC+1 schreef Frank Millman:
> "Luke Geelen" <luke.geelen at gmail.com> wrote in message
>
> news:ec88852e-1384-4aa5-834b-85135be94ab9 at googlegroups.com...
>
> > Op zaterdag 15 februari 2014 10:18:36 UTC+1 schreef Luke Geelen:
>
> > hello,
>
> >
>
> > i have been working on a python resistor calculator to let my class show
>
> > what you can do with python.
>
> >
>
> > now i have a script that makes the more speekable value of the resistance
>
> > (res)
>
> >
>
> [...]
>
> >
>
> > i commented it because it doesn't work (yet), when i have a resistance of
>
> >
>
> > 9.9 Giga ohms it says it is 9 giga ohms. it seems to work with natural
>
> > number, anyway of using decimals insted so that it says : the resistance
>
> > is 9.9 Giga Ohms instead of 9 ?
>
> >
>
>
>
> You don't say which version of python you are using.
>
>
>
> If you are using python2, an integer divided by an integer always returns an
>
> integer -
>
>
>
> >>> 10/3
>
> 3
>
>
>
> It was changed in python3 to return a float -
>
>
>
> >>> 10/3
>
> 3.3333333333333335
>
>
>
> You can reproduce the python3 behaviour in python2 by adding a 'future'
>
> directive -
>
>
>
> >>> from __future__ import division
>
> >>> 10/3
>
> 3.3333333333333335
>
>
>
> HTH
>
>
>
> Frank Millman
how (and where) would i add this rule into a script? by import or the calculation?
More information about the Python-list
mailing list