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
🌐
Replit
replit.com › home › discover › how to remove the decimal in python
How to remove the decimal in Python | Replit
March 3, 2026 - The int() function offers a straightforward way to remove a decimal by truncating the number. This means it simply cuts off everything after the decimal point without any rounding.
🌐
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)

🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-remove-all-decimals-from-a-number-using-python
How to remove all decimals from a number using Python? - GeeksforGeeks
July 23, 2025 - To use the truncate function, first, the math module must be imported, using trunc( ) function without defining the math( ) module gives an error. By using math.trunc( ) function a number can be truncated in python.
🌐
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....
🌐
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 - ... The built-in int() function takes a float and converts it to an integer, thereby truncating a float value by removing its decimal places. The int() function works differently than the round...
🌐
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.
Find elsewhere
🌐
Bobby Hadz
bobbyhadz.com › blog › python-get-number-without-decimal-places
Remove the Decimal part from a Float in Python | bobbyhadz
April 9, 2024 - The math.trunc method takes a number, removes its fractional part and returns its integer part. The math.trunc() method rounds towards zero.
🌐
Saturn Cloud
saturncloud.io › blog › how-to-remove-decimal-points-in-pandas-a-guide-for-data-scientists
How to Remove Decimal Points in Pandas A Guide for Data Scientists | Saturn Cloud Blog
December 23, 2023 - In this article, we’ve explored ... in Python. These methods include using the round() function, the astype() function, the apply() function with a lambda function, and the floor() function....
🌐
Python Guides
pythonguides.com › remove-decimal-numbers-in-python
Remove Decimal Numbers in Python
September 2, 2025 - This is another way to remove decimal numbers in Python using the %d placeholder. temperature = 29.8 print('%d'%temperature) print(type(temperature)) ... You can see the output in the screenshot below.
🌐
Java2Blog
java2blog.com › home › python › how to remove decimals in python
How to Remove Decimals in Python - Java2Blog
October 2, 2023 - Quick Solution To Remove decimals in Python, use int() function. ... Please note that when we remove decimal places, number before decimal point(.) will remain the same. If you want to round it up or down, then you should use round() instead.
🌐
TradingCode
tradingcode.net › python › math › truncate-decimals
Truncate numbers to decimal places in Python • TradingCode
To use the custom truncate() function we call it with two values: a floating-point value and the number of decimal places to truncate to. For example: ... Truncation is something else than rounding.