As no one has added it, it should be noted that going forward from Python 2.6+ the recommended way to do string formating is with format, to get ready for Python 3+.

print ["{0:0.2f}".format(i) for i in a]

The new string formating syntax is not hard to use, and yet is quite powerfull.

I though that may be pprint could have something, but I haven't found anything.

Answer from Esteban Küber on Stack Overflow
🌐
Medium
medium.com › @coucoucamille › float-formatting-in-python-ccb023b86417
Simple Float Formatting in Python | by Coucou Camille | Medium
June 15, 2022 - Python’s built-in format() function allows you to format float in any way you prefer. Syntax: {:.2f}.format(num) for rounding to 2 decimal places. ... Syntax: "{:+.2f}".format(num) for positive sign + ; and "{:-.2f}".format(num) for positive ...
Discussions

How can I control the number of decimals when printing a float?
value = 123.456789 for p in range(1, 11): print(f'{value:.{p}f}') This prints: 123.5 123.46 123.457 123.4568 123.45679 123.456789 123.4567890 123.45678900 123.456789000 123.4567890000 More on reddit.com
🌐 r/learnpython
8
4
August 5, 2021
Trying to format a list of floats with f-strings
You can't format an entire list all at once. You have to format each number individually, and then unpack that to print it: print("Roots:", *(f"{x:.3f}" for x in roots)) or you could use join to combine the formatted numbers: print("Roots:", ' '.join(f"{x:.3f}" for x in roots)) More on reddit.com
🌐 r/learnpython
6
2
July 23, 2018
How to use the float() command to create 2 decimal places instead of one in a product of 2 numbers [the product is dollar amount]
You generally don't round until you go to display the value. You can use round for that, but since you just want to display it with two digits, you can use string formatting . In your case, something like print(f'{totalPay:.2f}'). .2f is the format specifier, saying round the float (f) to two decimal places (.2). More on reddit.com
🌐 r/learnpython
9
7
January 28, 2020
Stuck. Help with keeping trailing zeros.
You're confusing data with the representation of that data. You're not "losing" the trailing zero because -91.990 is the same as -91.99; these are just two different representations of the same piece of data. If you want to show a number to three decimal places you don't have to change the number itself. Instead, you change the way you convert that number into a string to be displayed. You can use string formatting to get what you want: print('{:.3f}'.format(-91.99)) More on reddit.com
🌐 r/learnpython
2
1
December 11, 2014
🌐
Python.org
discuss.python.org › python help
General way to print floats without the .0 part - Python Help - Discussions on Python.org
May 19, 2024 - I’m building SVG code using data interpolation (f-strings and .format), and I have elements (the size of the graph for one) that are internally floats but which are usually integers. But when printing floats, the .0 part is always included. Is there a standard str-interpolation idiom that ...
🌐
The Teclado Blog
blog.teclado.com › python-formatting-numbers-for-printing
Formatting Numbers for Printing in Python - The Teclado Blog
March 23, 2023 - For large numbers we often write a separator character (usually a comma, space, or period) to make it easier to read. We can specify this in Python using a comma or underscore character after the colon. x = 1000000 print(f"{x:,}") # 1,000,000 print(f"{x:_}") # 1_000_000 · This also works with floats, and the precision formatting, with the comma coming first:
🌐
Real Python
realpython.com › how-to-python-f-string-format-float
How to Format Floats Within F-Strings in Python – Real Python
April 24, 2024 - >>> value = 13579+0.0245j >>> print( ... # Write your solution here ... ) The real part is 1.36E+04 and the imaginary part 2.45E-02. See if you can work out the required format specifiers. Remember, you’re aiming for an uppercase E so you may need to read the documentation. You’ll find possible solutions in the downloadable materials that accompany this tutorial. ... The Python float type limits you to 64 bits of storage for storing your numbers.
🌐
Analytics Vidhya
analyticsvidhya.com › home › 6 ways to round floating value to two decimals in python
6 Ways to Round Floating Value to Two Decimals in Python
November 4, 2024 - By applying the .2f format specifier within the format() method and using the "{:.2f}" format string, the number is formatted to have two decimal places. The resulting formatted_number is then printed, which outputs 3.14 ...
🌐
freeCodeCamp
freecodecamp.org › news › 2f-in-python-what-does-it-mean
%.2f in Python – What does it Mean?
June 22, 2022 - You can play around with the code to see what happens as you change the number in the formatter. Another formatting method we can use with floating point numbers in Python is the %d formatter.
Find elsewhere
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › functions › format.html
format — Python Reference (The Right Way) 0.1 documentation
>>> #This example illustrates the use of [type] option on integers >>> format(2, 'b') '10' >>> format(2, 'b') '10' >>> format(2, 'c') '\x02' >>> format(2, 'd') '2' >>> format(100, 'o') '144' >>> format(100, 'x') '64' >>> format(100, 'n') '100' >>> format(100) '100' >>> #This example illustrates the use of [type] option on floats >>> format(3.13592, 'e') '3.135920e+00' >>> format(3.13592, 'E') '3.135920E+00' >>> format(3.13592, 'f') '3.135920' >>> format(3.13592, 'g') '3.13592' >>> format(3.13592, '.2g') '3.1' >>> format(3.13592, '%') '313.592000%' >>> format(3.13592, '.2%') '313.59%' >>> format(3.13592, 'n') '3.13592'
🌐
W3Schools
w3schools.com › python › python_string_formatting.asp
Python String Formatting
A modifier is included by adding a colon : followed by a legal formatting type, like .2f which means fixed point number with 2 decimals: ... You can perform Python operations inside the placeholders. ... price = 59 tax = 0.25 txt = f"The price is {price + (price * tax)} dollars" print(txt) Try it Yourself »
🌐
DataCamp
campus.datacamp.com › courses › data-types-in-python › numeric-data-types-booleans-and-sets
Printing floats | Python
For example, if we wanted to format a variable in an f string as a float, we can use the f format specifier, such as: print(f"{some_variable:f}").
🌐
TutorialsPoint
tutorialspoint.com › how-to-format-a-floating-number-to-fixed-width-in-python
How to format a floating number to fixed width in Python?
November 13, 2024 - We can format a floating-point number to a fixed width by using Python's f-strings, in below code '.2f' specifies that the number should formatted as a floating-point number with 2 decimal places. number = 123.4568 formatted = f"{number:10.2f}" print(formatted)
🌐
Python Course
python-course.eu › python-tutorial › formatted-output.php
22. Formatted Output | Python Tutorial | python-course.eu
November 8, 2023 - Finally, the last character "f" of our placeholder stands for "float". If you look at the output, you will notice that the 3 decimal digits have been rounded. Furthermore, the number has been preceded in the output with 3 leading blanks. The first placeholder "]" is used for the first component of our tuple, i.e. the integer 453. The number will be printed with 5 characters.
🌐
mkaz.blog
mkaz.blog › working-with-python › string-formatting
Python String Formatting: Complete Guide
Usage: print(f"{NUMBER:FORMAT}") ... Minimum field width · ,: Use comma as thousands separator · precision: Digits after decimal point · type: f (float), d (decimal), e (scientific), % (percentage) F-strings support more than just variable substitution - you can include ...
🌐
Appdividend
appdividend.com › 2022 › 06 › 23 › how-to-format-float-values-in-python
How to Format Float Values in Python
December 13, 2025 - # Define a floating-point value value = 123.45678 formatted_value = round(value, 3) print("Three decimals:", formatted_value) # Output: 123.457 formatted_value = round(value, 2) print("Two decimals:", formatted_value) # Output: 123.46 formatted_value = round(value, 1) print("One decimal:", formatted_value) # Output: 123.5
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-output-formatting
Python - Output Formatting - GeeksforGeeks
Python · # Advanced formatting with positional and named arguments # Mixing positional and named arguments template = "Number one portal is {0}, {1} and {other}." print(template.format("Geeks", "For", other="Geeks")) # Format integers and floats with specified width and precision print("Geeks :{0:2d}, Portal :{1:8.2f}".format(12, 0.5534)) # Demonstrate order swapping and formatting precision print("Second argument: {1:3d}, first one: {0:8.2f}".format(47.42, 11)) # Using named arguments for clarity in complex formats print("Geeks: {a:5d}, Portal: {p:8.2f}".format(a=453, p=59.058)) Output ·
Published   July 11, 2025
🌐
AskPython
askpython.com › home › python floating point formatting: 2 simple methods
Python Floating Point Formatting: 2 Simple Methods - AskPython
April 10, 2025 - In this example, the :.2f inside the curly braces states that the floating-point number should be formatted with two decimal places. Running this code would output 123.46. Specifying Width and Precision · value = 123.456789 formatted_value = f”{value:10.2f}” print(formatted_value) f-string_example2 · Here, :10.2f states that the total width of the formatted string should be 10 characters, including two decimal places. The output, in this case, would be 123.46 · Python’s format method offers a versatile approach to string formatting.
🌐
AskPython
askpython.com › home › understanding the print format %.3f in python
Understanding the Print Format %.3f in Python - AskPython
March 30, 2023 - In Python, the “%.3f” format specifier is a method for formatting floating-point numbers to display only three decimal places. This is achieved using the ‘%’ operator along with the ‘%.nf’ format specifier, where ‘n’ determines ...
🌐
Finxter
blog.finxter.com › home › learn python blog › 5 best ways to format and print lists of floats in python
5 Best Ways to Format and Print Lists of Floats in Python - Be on the Right Side of Change
February 24, 2024 - float_list = [3.14159265, 1.6180339, 2.7182818] formatted_list = ['{:.2f}'.format(i) for i in float_list] print(formatted_list) ... This approach uses a list comprehension to create a new list of strings, with each float formatted to two decimal places. The .2f inside the curly braces tells the format() function to convert the floating-point number to a string with 2 decimal places. The "%.2f" operator is an older formatting option in Python, known as printf-style String Formatting.
🌐
PyFormat
pyformat.info
PyFormat: Using % and .format() for great good!
Of course it is also possible to format numbers. ... Similar to strings numbers can also be constrained to a specific width. ... Again similar to truncating strings the precision for floating point numbers limits the number of positions after the decimal point.