[Tutor] float question

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Tue Dec 20 09:38:11 CET 2005



On Mon, 19 Dec 2005, linda.s wrote:

> what does 2 mean in %2.4f ?

Hello,

It's a "minimal field width" modifier, according to:

    http://docs.python.org/lib/typesseq-strings.html


Let's try experimenting with it.

######
>>> '%20f' % 3.14
'            3.140000'
>>> '%20.2f' % 3.14
'                3.14'
######


Does this make sense?  If you have more questions, please feel free to
ask.



More information about the Tutor mailing list