> hongy... wrote
>
> This method doesn't work, as shown below:
>
? b
>
> [0.0, -1.0, 0.0, 0.25]
> [1.0, 0.0, 0.0, 0.25]
> [0.0, 0.0, 1.0, 0.25]
> [0.0, 0.0, 0.0, 1.0]
>
> a
>
> 0 0 0 1
>
# ---
Using
debian 11.3 bullseye
python 3.9
On Thursday, May 19, 2022 at 5:26:25 AM UTC+8, Cousin Stanley wrote:
> #!/usr/bin/env python3
>
> '''
> NewsGroup comp.lang.python
>
> Subject .. Convert the decimal numbers
> expressed in a numpy.ndarray
> into a matrix representing elements
#!/usr/bin/env python3
'''
NewsGroup comp.lang.python
Subject .. Convert the decimal numbers
expressed in a numpy.ndarray
into a matrix representing elements
in fractiona
Date . 2022-05-
On Tue, 17 May 2022 17:20:54 +0100, MRAB
declaimed the following:
>As it's just a simple replacement, I would've thought that the 'obvious'
>solution would be:
> a = a.replace("'", "")
Mea culpa...
Guess it's time for me to review the library reference for basic data
types
On 2022-05-17 16:21, Peter J. Holzer wrote:
On 2022-05-16 20:48:02 -0400, Dennis Lee Bieber wrote:
On Mon, 16 May 2022 17:22:17 -0700 (PDT), "hongy...@gmail.com"
declaimed the following:
>a=re.sub(r"'","",a)
Explain what you believe this operation is doing, show us the input and
the ou
On 2022-05-16 20:48:02 -0400, Dennis Lee Bieber wrote:
> On Mon, 16 May 2022 17:22:17 -0700 (PDT), "hongy...@gmail.com"
> declaimed the following:
> >a=re.sub(r"'","",a)
>
> Explain what you believe this operation is doing, show us the input and
> the output.
>
> The best I can make
> On 17 May 2022, at 05:59, hongy...@gmail.com wrote:
>
> On Monday, May 16, 2022 at 11:27:58 PM UTC+8, Dennis Lee Bieber wrote:
>> On Mon, 16 May 2022 02:03:26 -0700 (PDT), "hongy...@gmail.com"
>> declaimed the following:
>>
>>
>>> print(lst)
>>
>> Printing higher level structures uses
On Monday, May 16, 2022 at 11:27:58 PM UTC+8, Dennis Lee Bieber wrote:
> On Mon, 16 May 2022 02:03:26 -0700 (PDT), "hongy...@gmail.com"
> declaimed the following:
>
>
> >print(lst)
>
> Printing higher level structures uses the repr() of the structure and
> its contents -- theoretically a fo
;",a)
> repr(a)
> print(repr(a))
> '[[0, -1, 0, 1/4], [1, 0, 0, 1/4], [0, 0, 1, 1/4], [0, 0, 0, 1]]'
> ```
> Best,
> HZ
See here [1] for the related discussion.
[1]
https://discuss.python.org/t/convert-the-decimal-numbers-expressed-in-a-numpy-ndarray-into-a-matrix-representing-elements-in-fractional-form/15780
--
https://mail.python.org/mailman/listinfo/python-list
On Monday, May 16, 2022 at 11:27:58 PM UTC+8, Dennis Lee Bieber wrote:
> On Mon, 16 May 2022 02:03:26 -0700 (PDT), "hongy...@gmail.com"
> declaimed the following:
>
>
> >print(lst)
>
> Printing higher level structures uses the repr() of the structure and
> its contents -- theoretically a fo
On Tuesday, May 17, 2022 at 8:48:27 AM UTC+8, Dennis Lee Bieber wrote:
> On Mon, 16 May 2022 17:22:17 -0700 (PDT), "hongy...@gmail.com"
> declaimed the following:
>
>
> >
> >I tried with the repr() method as follows, but it doesn't give any output:
> I have no idea what 50% of those libraries
On Mon, 16 May 2022 02:03:26 -0700 (PDT), "hongy...@gmail.com"
declaimed the following:
>print(lst)
Printing higher level structures uses the repr() of the structure and
its contents -- theoretically a form that could be used within code as a
literal. If you want human-readable str() yo
On Mon, 16 May 2022 17:22:17 -0700 (PDT), "hongy...@gmail.com"
declaimed the following:
>
>I tried with the repr() method as follows, but it doesn't give any output:
I have no idea what 50% of those libraries are supposed to do, and am
not going to install them just to try out your po
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
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 weerstand is %s,%s giga ohms" % (res2)
#elif
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)
On Wed, 20 Mar 2013 20:00:38 +, Grant Edwards wrote:
> On 2013-03-20, Alister wrote:
>
>> and a list comprehension would streamline things further
>>
>> t=[round(x*1.0/60),4 for x in range(1440)] #compatible with V2.7 &
>> V3.0)
>
> There's a typo in the above. It should be:
>
> t = [rou
On 2013-03-20, Alister wrote:
> and a list comprehension would streamline things further
>
> t=[round(x*1.0/60),4 for x in range(1440)] #compatible with V2.7 & V3.0)
There's a typo in the above. It should be:
t = [round((x*1.0/60),4) for x in range(1440)]
--
Grant Edwards gran
you can write
for i in range(...):
...
instead of incrementing manually.
When it is doing the cicle it can have all the decimal numbers, but I
need to print the result with only 4 decimal numbers
How can I define the number of decimal numbers I want to print in this
case? For example wit
hour.append([t])
>
> In many cases you can write
>
> for i in range(...):
>...
>
> instead of incrementing manually.
>
>> When it is doing the cicle it can have all the decimal numbers, but I
>> need to print the result with only 4 decimal numbers
>
stead of incrementing manually.
> When it is doing the cicle it can have all the decimal numbers, but I need
> to print the result with only 4 decimal numbers
>
> How can I define the number of decimal numbers I want to print in this
> case? For example with 4 decimal numbers,
>
> hour.append([t])
>
>
>
> When it is doing the cicle it can have all the decimal numbers, but I need to
> print the result with only 4 decimal numbers
>
>
>
> How can I define the number of decimal numbers I want to print in this case?
> For examp
So, I have this script that puts in a list every minute in 24 hours
hour=[]
i=0
t=-(1.0/60.0)
while i<24*60:
i = i+1
t = t+(1.0/60.0)
hour.append([t])
When it is doing the cicle it can have all the decimal numbers, but I need to
print the result with only 4 decimal numbers
How
In article <[EMAIL PROTECTED]>,
Scott David Daniels <[EMAIL PROTECTED]> writes:
|> Nick Maclaren wrote: (of fixed point)
|> > I am (just) old enough to remember when it was used for
|> > numeric work, and to have used it for that myself, but not old enough
|> > to have done any numeric work
Nick Maclaren wrote: (of fixed point)
> I am (just) old enough to remember when it was used for
> numeric work, and to have used it for that myself, but not old enough
> to have done any numeric work using fixed-point hardware.
You are using fixed point hardware today. Fixed point tracked t
we use floats with two decimals
>>> b = 222.33
>>> b
222.330001
they look like fix-point numbers (I had to look it up
http://en.wikipedia.org/wiki/Fixed-point :-D) but python stores it
(correct me if I am wrong) as a float (or double or quad or whatever).
If we want to work
In article <[EMAIL PROTECTED]>,
"per9000" <[EMAIL PROTECTED]> writes:
|>
|> just a thought: if you *always* work with "floats" with two decimals,
|> you are in fact working with integers, but you represent them as a
|> floats - confusing for the internal representation.
No, you aren't - you are
> just a thought: if you *always* work with "floats" with two decimals,
> you are in fact working with integers, but you represent them as a
> floats - confusing for the internal representation.
>
> So why not work with int(float * 100) instead? This way you only have
> to take care of roundoffs e
oops, should be something like this:
"int / int" = "int / int, int % int"
/per9000
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
just a thought: if you *always* work with "floats" with two decimals,
you are in fact working with integers, but you represent them as a
floats - confusing for the internal representation.
So why not work with int(float * 100) instead? This way you only have
to take care of roundoffs etc when
In article <[EMAIL PROTECTED]>,
Girish Sahani <[EMAIL PROTECTED]> wrote:
>
>I want to truncate every number to 2 digits after the decimal point. I
>tried the following but it doesnt work.
>
a = 2
b = 3
round(a*1.0 / b,2)
>0.67004
>
>Inspite of specifying 2 in 2nd attribut
MTD wrote:
> > The system cannot
> > accurately represent some integers,
>
> Er, I meant FLOATS. Doh.
You were also right the first time. But it only applies to integers
with more than 53 bits.
--
http://mail.python.org/mailman/listinfo/python-list
Sybren Stuvel wrote:
> Girish Sahani enlightened us with:
>> I want to truncate every number to 2 digits after the decimal point
> a = 2
> b = 3
> round(a*1.0 / b,2)
>> 0.67004
>
> If you want to format it, use '%.2f' % (float(a)/b)
Sybren has this right. If you follo
Girish Sahani a écrit :
> Hi,
>
> I want to truncate every number to 2 digits after the decimal point. I
> tried the following but it doesnt work.
>
a = 2
b = 3
round(a*1.0 / b,2)
> 0.67004
>
> Inspite of specifying 2 in 2nd attribute of round, it outputs all the
> dig
> The system cannot
> accurately represent some integers,
Er, I meant FLOATS. Doh.
Anyway, just to underline the example:
>>> x
0.3
>>> s = str(round(x,2))
>>> s
'0.67'
>>> f = float(s)
>>> f
0.67004
>>> f == round(x,2)
True
--
http://mail.python.org/mailman/listinf
> >>> a = 2
> >>> b = 3
> >>> round(a*1.0 / b,2)
> 0.67004
>
> Inspite of specifying 2 in 2nd attribute of round, it outputs all the
> digits after decimal.
This is because of floating point inaccuracy. The system cannot
accurately represent some integers, however it does its best to
a
Hi,
I want to truncate every number to 2 digits after the decimal point. I
tried the following but it doesnt work.
>>> a = 2
>>> b = 3
>>> round(a*1.0 / b,2)
0.67004
Inspite of specifying 2 in 2nd attribute of round, it outputs all the
digits after decimal.
--
http://mail.python.org
53 matches
Mail list logo