You can use the normalize method to remove extra precision.

>>> print decimal.Decimal('5.500')
5.500
>>> print decimal.Decimal('5.500').normalize()
5.5

To avoid stripping zeros to the left of the decimal point, you could do this:

def normalize_fraction(d):
    normalized = d.normalize()
    sign, digits, exponent = normalized.as_tuple()
    if exponent > 0:
        return decimal.Decimal((sign, digits + (0,) * exponent, 0))
    else:
        return normalized

Or more compactly, using quantize as suggested by user7116:

def normalize_fraction(d):
    normalized = d.normalize()
    sign, digit, exponent = normalized.as_tuple()
    return normalized if exponent <= 0 else normalized.quantize(1)

You could also use to_integral() as shown here but I think using as_tuple this way is more self-documenting.

I tested these both against a few cases; please leave a comment if you find something that doesn't work.

>>> normalize_fraction(decimal.Decimal('55.5'))
Decimal('55.5')
>>> normalize_fraction(decimal.Decimal('55.500'))
Decimal('55.5')
>>> normalize_fraction(decimal.Decimal('55500'))
Decimal('55500')
>>> normalize_fraction(decimal.Decimal('555E2'))
Decimal('55500')
Answer from senderle on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › how to terminate or remove the .0 point from an int.
r/learnpython on Reddit: How to terminate or remove the .0 point from an int.
December 9, 2022 -

Hello everyone,

I am still new to python and learning.

So I practiced some exercises and made an app that calculates the percentage from the number the user enters.

My question use, how can I terminate the .0 part if the user enters an Int and keep the decimal part if they enter a float?

so for example, 5% of 100 is 5 ( Int)

and 5.1% of 100 is 5.1 (float)

🌐
AskPython
askpython.com › home › how to format floats without trailing zeros?
How to Format Floats Without Trailing Zeros? - AskPython
May 12, 2023 - Python offers four effective methods to remove trailing zeros from float values: the to_integral() and normalize() functions, the str() and rstrip() functions, a while loop, and the float() function.
🌐
Reddit
reddit.com › r/learnpython › how to eliminate trailing zeros?
r/learnpython on Reddit: How to eliminate trailing zeros?
February 12, 2020 -

I have a float formatted to 2 decimal places. I need to eliminate the 2nd decimal place if it's a "0" but still keep 2 decimal places open for when its 2 whole numbers.

number = float(25.20458)
    print(format(number, ".2f"))
#Comes out as 25.20
#Need 25.2

Windows 10 and Python 3.7

🌐
Python Guides
pythonguides.com › remove-the-trailing-zeros-from-a-decimal-in-python
Remove Trailing Zeros from Decimal in Python
September 3, 2025 - We used str() to convert the variable to a string and then used the .rstrip(0), which stands for the right strip and removes the specified 0 argument from the end of the string. Python provides this simple technique to remove trailing zeros from decimals using the float() function.
🌐
Bobby Hadz
bobbyhadz.com › blog › python-remove-trailing-zeros-from-decimal
How to Remove the trailing Zeros from a Decimal in Python | bobbyhadz
Copied!from decimal import Decimal num = Decimal('1.230000') string = str(num) without_trailing_zeros = string.rstrip( '0').rstrip('.') if '.' in string else string result = Decimal(without_trailing_zeros) print(result) # 👉️ 1.23 ...
🌐
Python
docs.python.org › 3 › library › decimal.html
decimal — Decimal fixed-point and floating-point arithmetic
This has the same semantics as the unary plus operation, except that if the final result is finite it is reduced to its simplest form, with all trailing zeros removed and its sign preserved. That is, while the coefficient is non-zero and a multiple of ten the coefficient is divided by ten and the exponent is incremented by 1. Otherwise (the coefficient is zero) the exponent is set to 0. In all cases the sign is unchanged. For example, Decimal('32.100') and Decimal('0.321000e+2') both normalize to the equivalent value Decimal('32.1').
🌐
Kodeclik
kodeclik.com › remove-trailing-zeros-in-python-string
How to remove Trailing Zeros from a given Python String
July 15, 2025 - To keep the notation simple we reverse the string for use in an iterator and then re-reverse it (using string slicing operators) after the zeros are removed. mystring = "314.50600" inside = False newstring = '' for x in reversed(mystring): if (not(inside) and x=="0"): pass else: newstring = newstring + x inside = True answer = newstring[::-1] print(answer) ... The above code can be made more succinct using Python’s string slicing operators in a while loop.
Find elsewhere
🌐
Javatpoint
javatpoint.com › how-to-remove-decimal-in-python
How to Remove Decimal in Python - Javatpoint
How to Remove Decimal in Python with python, tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, operators, etc.
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-remove-all-decimals-from-a-number-using-python
How to remove all decimals from a number using Python? - GeeksforGeeks
March 27, 2025 - Explanation: This code converts floating-point numbers to integers using the int() function, which removes the decimal part. It then prints the converted values and shows the data types of the original and converted numbers using type(). ... ...
🌐
Python Forum
python-forum.io › thread-38493.html
method to remove zero digits from fraction in decimal
when a decimal number is a whole (integral, integer-like) number, it gets converted to string without the ".0". but if i take the result of calculation, such as conversion from Fahrenheit to Celsius,
🌐
AlgoMonster
algo.monster › liteproblems › 2710
2710. Remove Trailing Zeros From a String - In-Depth Explanation
In-depth solution and explanation for LeetCode 2710. Remove Trailing Zeros From a String in Python, Java, C++ and more. Intuitions, example walk through, and complexity analysis. Better than official and forum solutions.
🌐
Python Help
pythonhelp.org › tutorials › get-rid-of-0
How to get rid of that pesky .0 in Python
The round() function in Python can be used to round off a float value to a specified number of decimal places. We can use this function to remove the “.0” from a float value by rounding it to zero decimal places.
🌐
Replit
replit.com › home › discover › how to remove the decimal in python
How to remove the decimal in Python | Replit
March 3, 2026 - This means it simply cuts off everything after the decimal point without any rounding. In the example, when int() is applied to 42.75, it discards the .75 and returns the integer 42. This approach is fast and effective, especially when you need to isolate the whole number part of a float for calculations or formatting. It consistently truncates toward zero, making its behavior predictable for both positive and negative numbers. While int() simply truncates, Python's math module and the built-in round() function give you more precise control over how decimals are handled.