[Tutor] How to print numbers in scientific notation form?

Alan Gauld alan.gauld at btinternet.com
Sat Jun 28 17:04:31 CEST 2008


"Dick Moores" <rdm at rcblue.com> wrote 

> >>> print "%.4g" % 5.09879870978
> 5.099
> >>> print "%.4g" % .000009878
> 9.878e-006
> 
> How can I print all numbers in scientific notation form, and 
> designate the number of significant digits?

use %e instead of %g

Alan G



More information about the Tutor mailing list