Mega Code Archive
Categories
/
Python Tutorial
/
Data Type
Formatting float number, use the f specifier and supply the precision as a (dot) followed by the number of decimals
format = "Pi with three decimals: %.3f" from math import pi print format % pi