Without any warranty.
>>> def z(r):
... # r: int > 0
... t = log10(r)
... if t >= 12.0:
... prefix = ''
... prefix2 = ''
... elif t >= 9.0:
... prefix = 'giga'
... prefix2 = 'G'
... r = r / 1.0e9
... elif t >= 6.0:
... prefix = 'm
On Sun, Feb 16, 2014 at 1:30 PM, Steven D'Aprano
wrote:
> Even though I didn't ask the question, I learned something from the
> answer. Thank you.
Reason #1443694 for mailing lists rather than personal tutoring :) I
love this aspect of them.
ChrisA
--
https://mail.python.org/mailman/listinfo/py
On Sat, 15 Feb 2014 14:34:45 -0700, Ian Kelly wrote:
> On Sat, Feb 15, 2014 at 11:57 AM, Luke Geelen
> wrote:
>> hey, is it possible to remove the .0 if it is a valua without something
>> behind the poit (like 5.0 gets 5 but 9.9 stays 9.9
>
> The ':g' format specifier will trim off trailing zero
On Sat, Feb 15, 2014 at 11:57 AM, Luke Geelen wrote:
> hey, is it possible to remove the .0 if it is a valua without something
> behind the poit (like 5.0 gets 5 but 9.9 stays 9.9
The ':g' format specifier will trim off trailing zeroes, e.g.:
>>> '{:g}'.format(5.0)
'5'
It also switches to expo
On Sat, 15 Feb 2014 10:57:20 -0800, Luke Geelen wrote:
> hey, is it possible to remove the .0 if it is a valua without something
> behind the poit (like 5.0 gets 5 but 9.9 stays 9.9
Yes, but not easily. First, check the number's fractional part, and if it
is zero, convert it to an int:
# Here,
On 15/02/2014 18:57, Luke Geelen wrote:
Op zaterdag 15 februari 2014 18:42:51 UTC+1 schreef Luke Geelen:
Op zaterdag 15 februari 2014 18:23:20 UTC+1 schreef Ian:
On Sat, Feb 15, 2014 at 10:17 AM, Luke Geelen wrote:
If i do set form thing in my script i get
Invalide syntax pointi
Op zaterdag 15 februari 2014 18:42:51 UTC+1 schreef Luke Geelen:
> Op zaterdag 15 februari 2014 18:23:20 UTC+1 schreef Ian:
>
> > On Sat, Feb 15, 2014 at 10:17 AM, Luke Geelen wrote:
>
> >
>
> > > If i do set form thing in my script i get
>
> >
>
> > > Invalide syntax pointing at the last w
Op zaterdag 15 februari 2014 18:23:20 UTC+1 schreef Ian:
> On Sat, Feb 15, 2014 at 10:17 AM, Luke Geelen wrote:
>
> > If i do set form thing in my script i get
>
> > Invalide syntax pointing at the last word of the form rule
>
>
>
> Please copy and paste the exact code you ran along with the
On Sat, Feb 15, 2014 at 10:17 AM, Luke Geelen wrote:
> If i do set form thing in my script i get
> Invalide syntax pointing at the last word of the form rule
Please copy and paste the exact code you ran along with the full text
of the exception into your post. Paraphrasing it like this doesn't
h
On Sat, Feb 15, 2014 at 2:18 AM, wrote:
> 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)
>
> #if len(str(res)) > 9:
> # res2 = res / 10
If i do set form thing in my script i get
Invalide syntax pointing at the last word of the form rule
--
https://mail.python.org/mailman/listinfo/python-list
luke.gee...@gmail.com wrote:
> 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)
>
> #if len(str(res)) > 9:
> # res2 = res / 10
> # print "de
"Frank Millman" wrote in message
news:ldngnf$c3r$1...@ger.gmane.org...
>
> "Luke Geelen" wrote in message
> news:ae0da085-6c41-4166-92d2-92611a990...@googlegroups.com...
>> Op zaterdag 15 februari 2014 11:04:17 UTC+1 schreef Frank Millman:
>>> "Luke Geelen" wrote in message
>>>
>>> news:ec888
"Luke Geelen" wrote in message
news:ae0da085-6c41-4166-92d2-92611a990...@googlegroups.com...
> Op zaterdag 15 februari 2014 11:04:17 UTC+1 schreef Frank Millman:
>> "Luke Geelen" wrote in message
>>
>> news:ec88852e-1384-4aa5-834b-85135be94...@googlegroups.com...
>>
[...]
>>
>> You can reproduc
Op zaterdag 15 februari 2014 11:04:17 UTC+1 schreef Frank Millman:
> "Luke Geelen" wrote in message
>
> news:ec88852e-1384-4aa5-834b-85135be94...@googlegroups.com...
>
> > Op zaterdag 15 februari 2014 10:18:36 UTC+1 schreef Luke Geelen:
>
> > hello,
>
> >
>
> > i have been working on a pytho
On Sat, Feb 15, 2014 at 9:04 PM, Frank Millman wrote:
> 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.3335
>
> You can reproduce the python3 behaviour in python2
"Luke Geelen" wrote in message
news:ec88852e-1384-4aa5-834b-85135be94...@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 s
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)
>
>
>
> #if len(str(res)
18 matches
Mail list logo