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
Discussions

math - Python - Keep the trailing zeros on a float value - Stack Overflow
I'm writing a function that takes a number, it can either be a float or an integer, and returns an integer indicating how many significant figures that number has. Here is an example >>> i... More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - How to add 0's to a floating point number? - Stack Overflow
Using Python 2.7. If I want to subtract 120.00 - 30, I get 90.0 but I want 90.00. I've tried using the format function: a = 120.00 - 30 format(a, '.2f') which gives me a string of '90.00', but I ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
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 10, 2014
python - Adding trailing zeros to floating decimals - Stack Overflow
I am trying to write some floats numbers as decimals with 14 digit after floating point. So i want to add traling zeros for numbers who have less than 14 digits . however, when I use the folowing, it More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Bobby Hadz
bobbyhadz.com โ€บ blog โ€บ python-add-zeros-after-decimal
Add zeros to a Float after the Decimal in Python | bobbyhadz
April 8, 2024 - 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 ย  November 19, 2019
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 10, 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

๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
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
๐ŸŒ
pythontutorials
pythontutorials.net โ€บ blog โ€บ how-to-print-float-to-n-decimal-places-including-trailing-0s
How to Print/Convert a Float to N Decimal Places with Trailing Zeros (Avoid Rounding Errors) โ€” pythontutorials.net
For example, displaying 10.5 as 10.50 (two decimal places with trailing zeros) or ensuring 3.14159 rounds to 3.14 (not 3.15) when truncated to two decimals. While this seems straightforward, floating-point numbers (floats) in programming languages are prone to two critical issues: trailing zero omission (e.g., 10.5 instead of 10.50) and rounding errors (e.g., 0.1 + 0.2 = 0.30000000000000004 in Python).
๐ŸŒ
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
๐ŸŒ
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....