How to print floating point in scientific format?

sdhyok sdhyok at yahoo.com
Sun Aug 10 21:21:10 CEST 2003


Cousin, you are right.
But, do you want to write for loops
whenever you print arrays? 
Maybe not if you are a hard-core scientific programmer.

"Cousin Stanley" <CousinStanley at hotmail.com> wrote in message news:<bh361p$u9lvt$1 at ID-130333.news.uni-berlin.de>...
> The conversion to e format in the print statement
> seems to work OK if I iterate over the items in the array ....
> 
> >>> import Numeric as N
> >>>
> >>> x = N.arange( 10. )
> >>>
> >>> print x
>  [ 0.  1.  2.  3.  4.  5.  6.  7.  8.  9.]
> >>>
> >>> for this_item in x :
> ...     print '%e' % this_item
> ...
> 0.000000e+000
> 1.000000e+000
> 2.000000e+000
> 3.000000e+000
> 4.000000e+000
> 5.000000e+000
> 6.000000e+000
> 7.000000e+000
> 8.000000e+000
> 9.000000e+000
> >>>




More information about the Python-list mailing list