from math import pi print '%10f' % pi # Field width 10 print '%10.2f' % pi # Field width 10, precision 2 print '%.2f' % pi # Precision 2 print '%.5s' % 'Guido van Rossum' print '%.*s' % (5, 'Guido van Rossum')