bob gailer wrote:
On 12/2/2010 2:09 PM, Richard D. Moores wrote:
[snip]
I found nothing that helped as much as you have already.
In the reference (for 2.6.2) under print statement I find:
"print evaluates each expression in turn and writes the resulting object
to standard output (see below
On 12/2/2010 2:09 PM, Richard D. Moores wrote:
[snip]
I found nothing that helped as much as you have already.
In the reference (for 2.6.2) under print statement I find:
"print evaluates each expression in turn and writes the resulting object
to standard output (see below). If an object is
On Thu, Dec 2, 2010 at 03:13, Alan Gauld wrote:
>
> "Richard D. Moores" wrote
>
> s = [.1,.1,.1,.1,.1,.1,.1,.1,.1,.1]
> sum(s)
>>
>> 0.
>
> This uses repr() to display the result
>
> print(sum(s))
>>
>> 1.0 Why?
>
> This uses str() to display the result.
>
> In ma
"Richard D. Moores" wrote
s = [.1,.1,.1,.1,.1,.1,.1,.1,.1,.1]
sum(s)
0.
This uses repr() to display the result
print(sum(s))
1.0 Why?
This uses str() to display the result.
In many cases str() calls repr() but in other cases str() is a more
user
friendly format.
>>> s = [.1,.1,.1,.1,.1,.1,.1,.1,.1,.1]
>>> sum(s)
0.
>>> print(sum(s))
1.0 Why?
>>> f = 0.
>>> f**100
0.9889
>>> print(f**100)
1.0 Why?
>>> f**1
0.99988898
>>> print(f**1)
0.
>>> from math import fsum
>>> fsum(s)
1.0