formatting float number, use the f specifier and supply the precision as a . (dot) followed by the number of decimals : float format « Data Type « Python Tutorial






format = "Pi with three decimals: %.3f" 
from math import pi 
print format % pi








2.5.float format
2.5.1.formatting float number, use the f specifier and supply the precision as a . (dot) followed by the number of decimals
2.5.2.Formatting Numbers
2.5.3.Floating Point and Exponential Notation Output
2.5.4.format float numbers