If this is just for printing... f'{my_float:.6f}. If you actually need that level of precision, you're likely to run into rounding issues, but you could try something like this: int(my_float * (10**6)) / (10**6) Answer from member_of_the_order on reddit.com
🌐
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)

Find elsewhere
🌐
datagy
datagy.io › home › python posts › python strings › python: truncate a float (6 different ways)
Python: Truncate a Float (6 Different Ways) • datagy
April 14, 2024 - This is differently than the round() function, as it does not round up. It’s also different from the floor(), which returns an integer now greater than a number. Let’s see how we can use the int() function to truncate a float in Python:
🌐
Replit
replit.com › home › discover › how to remove the decimal in python
How to remove the decimal in Python | Replit
March 3, 2026 - String formatting lets you control how numbers appear without changing their underlying value. The f-string format specifier :.0f tells Python to display a number with zero decimal places, which also rounds it to the nearest whole number.
🌐
Bobby Hadz
bobbyhadz.com › blog › python-get-number-without-decimal-places
Remove the Decimal part from a Float in Python | bobbyhadz
April 9, 2024 - Use the `math.floor()` method to remove the decimal part from a float, e.g. `result = math.floor(3.999)`.
🌐
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 - A gnboorse-rom module is that library of python which helps you convert roman numerals into decimal number and decimal number into roman numerals .It will do conversion of values upto 3999 both in roman numerals and decimal system .
🌐
W3Schools
w3schools.com › python › ref_math_trunc.asp
Python math.trunc() Method
Python Examples Python Compiler ... print(math.trunc(8.32)) print(math.trunc(-99.29)) Try it Yourself » · The math.trunc() method returns the truncated integer part of a number....
🌐
Quora
quora.com › How-do-you-truncate-to-2-decimal-places-in-Python
How to truncate to 2 decimal places in Python - Quora
2) For decimal-accurate financial or fixed-point work — use decimal.Decimal with quantize and ROUND_DOWN: ... To truncate a number to 2 decimal places (drop extra digits without rounding) use one of these safe methods depending on type and needs.