Format it to 6 decimal places:

format(value, '.6f')

Demo:

>>> format(2.0, '.6f')
'2.000000'

The format() function turns values to strings following the formatting instructions given.

Answer from Martijn Pieters on Stack Overflow
🌐
Bobby Hadz
bobbyhadz.com › blog › python-add-zeros-after-decimal
Add zeros to a Float after the Decimal in Python | bobbyhadz
Use the `format()` function to add zeros to a float after the decimal, e.g. `result = format(my_float, '.3f')`.
🌐
Kaggle
kaggle.com › questions-and-answers › 388405
[Python] Adding trailing zeros to every value in a column ...
Checking your browser before accessing www.kaggle.com · Click here if you are not automatically redirected after 5 seconds
🌐
Tutorial Reference
tutorialreference.com › python › examples › faq › python-how-to-add-trailing-zeros-after-decimal-in-float
How to Format Floats with Trailing Zeros in Python | Tutorial Reference
This guide explains how to format floating-point numbers in Python to include a specific number of trailing zeros after the decimal point. This is primarily a formatting operation (creating a string representation), as Python floats do not inherently maintain trailing zeros.
🌐
Python
bugs.python.org › issue32790
Issue 32790: Keep trailing zeros in precision for string format option g - Python tracker
This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide · This issue has been migrated to GitHub: https://github.com/python/cpython/issues/76971
🌐
YouTube
youtube.com › speak with ujjwal
How to add zero at the end of a decimal number in Python ? - YouTube
How to add trailing zero at the end of a decimal number in Python format function in Python
Published   July 21, 2020
Views   1K
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-add-trailing-zeros-to-string
Add trailing Zeros to string-Python - GeeksforGeeks
July 11, 2025 - Let’s explore some efficient approaches to achieve this in Python. This is the most efficient way to add trailing zeros. By multiplying the string '0' with N, we get a string of N zeros.
Find elsewhere
🌐
Reddit
reddit.com › r/learnpython › stuck. help with keeping trailing zeros.
r/learnpython on Reddit: Stuck. Help with keeping trailing zeros.
December 13, 2014 -

I'm doing a codeeval problem where I have to sort numbers and KEEP the trailing zeros. Whenever I convert the string to a float, I lose the trailing zero and I've been really stuck on this.

Here is my code: http://pastebin.com/vjzQqRqK

Here's some random numbers I've been working with:

-91.990 33.414 -43.337 95.988 27.428 49.803 -68.933 -49.591 -66.642 35.075 67.539 92.211 -59.036 -11.980 47.774 92.474 33.761 11.232 -81.835 19.262 77.708 -39.278 -0.669 81.392 -93.143 -50.236 -81.395 96.431 -1

Everything works expect I cannot figure out how to keep the trailing zero on numbers such as -91.990

🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.format_float_positional.html
numpy.format_float_positional — NumPy v2.4 Manual
‘0’ : trim all but the zero before the decimal point. Insert the zero if it is missing. ‘-’ : trim trailing zeros and any trailing decimal point
🌐
Python
docs.python.org › 3 › library › decimal.html
decimal — Decimal fixed-point and floating-point arithmetic
The decimal module was designed to support “without prejudice, both exact unrounded decimal arithmetic (sometimes called fixed-point arithmetic) and rounded floating-point arithmetic.” – excerpt from the decimal arithmetic specification. The module design is centered around three concepts: the decimal number, the context for arithmetic, and signals. A decimal number is immutable. It has a sign, coefficient digits, and an exponent. To preserve significance, the coefficient digits do not truncate trailing zeros.
🌐
Stack Overflow
stackoverflow.com › questions › 70972937 › adding-trailing-zeros-to-floating-decimals
python - Adding trailing zeros to floating decimals - Stack Overflow
however, when I use the folowing, it performs a random approximation rather than adding zeros . print ('%.14f' % 381.949875) print ('%.14f' % 383.558625 ) print ( '%.14f' % 382.593375) ... It is definitely something related to stackoverflow.com/questions/588004/… as 381.949875 + 0.00000000000001 == 381.949875. I would have to check in more detail but I suspect that in order to do the print, behind the curtains the first number is added to a very small 15 digit after the decimal number in order to ensure the 0 padding.
🌐
Python Forum
python-forum.io › thread-7788.html
Controlling trailing zeros with rounding?
I'm trying to print out floats in currency format, but no matter what numbers I specify for rounding parameters, it only prints out one 0 after the decimal point: #!/usr/bin/env python3 #FormattingStuff.py def listOfFloats(): floatsList = [20.00...
Top answer
1 of 4
34

You can use the format method on strings to specify how many decimal places you want to represent:

>>> "{:.2f}".format(1.5)
'1.50'

But even better would be to use the decimal module for representing money, since representation issues with binary floats can give you slightly off results if you're doing arithmetic. The documentation for that module mentions some of those issues specifically - one of the most interesting ones for money applications is:

>>> 0.1+0.1+0.1-0.3
5.551115123125783e-17
>>> from decimal import Decimal
>>> Decimal('.1') + Decimal('.1') + Decimal('.1') - Decimal('.3')
Decimal('0.0')
2 of 4
20

The proposed solutions do not work when the magnitude of the number is not known in advance, which is common in scientific applications rather than in money-related ones. I give an alternative solution for those, like me, coming to this question looking for the scientific case.

For example, if I want to print x = 1.500e-4 to three significant digits (common situation when dealing with measurements with a given uncertainty), the following command obviously does not give the correct result:

x = 1.500e-4
print(f"{x:.3f}")

----> 0.000

Here I used the modern Python 3.6+ f-strings for the formatting.

One may think of using the g format specifier, but this also does not give the desired result to three significant digits as the trailing zero is omitted:

x = 1.500e-4
print(f"{x:.3g}")

----> 0.00015

The correct answer can be obtained using the g format specifier together with a rather obscure option, the hash character #, of the format-specification mini language, in the following way:

x = 1.500e-4
print(f"{x:#.3g}")

----> 0.000150

This formatting also works unchanged in the simpler case of the original question:

x = 1.500
print(f"{x:#.3g}")

----> 1.50
🌐
Medium
medium.com › @coucoucamille › float-formatting-in-python-ccb023b86417
Simple Float Formatting in Python | by Coucou Camille | Medium
June 15, 2022 - ... Syntax: "{:+.2f}".format(num) ..."{:-.2f}".format(8.9998)) >>> '-3.14' Syntax: "{:.2f}%".format(num) or "{:.2%}".format(num) to format num as a percentage with 2 decimal places....
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.format_float_positional.html
numpy.format_float_positional — NumPy v2.2 Manual
‘0’ : trim all but the zero before the decimal point. Insert the zero if it is missing. ‘-’ : trim trailing zeros and any trailing decimal point