You can call int() on the end result:

>>> int(2.0)
2
Answer from TerryA on Stack Overflow
Discussions

integer - Python how to remove decimal? - Stack Overflow
I've found some other topics on this but I couldn't get it to work. Please pardon my naivety with Python. Berekening1 = 8.5 Berekening2 = 8.1+4.8 Berekening3 = 8*10 Berekening4 = 3 x = Berekening1 * More on stackoverflow.com
🌐 stackoverflow.com
How to terminate or remove the .0 point from an int.
Try using the g flag when you print it. x = 5.0 y = 5.1 print("regular print:", x, y) print("with g flag:", f"{x:g} {y:g}") More on reddit.com
🌐 r/learnpython
5
2
December 9, 2022
Int to String without decimal points?
Hey guys, I’ve made a function to get the dimensions of my bounding box and i’m putting them into a sentence as a string by using str(varx)+srt(vary) etc. I have even rounded the Integers by using Round() but when i turn them into strings, everything comes up with 1 decimal precision that’s ... More on discourse.mcneel.com
🌐 discourse.mcneel.com
6
0
April 20, 2023
[deleted by user]
This issue is floating-point numbers cannot always precisely represent decimal fractions. I'd revise the approach to something more like: a. Read the floating-point number as a string. b. Split the string at the decimal point into two parts. c. Convert the whole part to an integer and leave the decimal part as a string More on reddit.com
🌐 r/C_Programming
27
8
November 22, 2023
🌐
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 - We have to remove all decimals from a number and get the required output using Python. There are several ways to achieve this, depending on whether you want to simply truncate the decimal part, round it or perform other manipulations. For example, number is 12.345 then result is 12. int( ) is a built-in function used to convert any value into an integer number. ... a = 44.560 b = 856.9785623 c = 9999.99 # Type conversion float to int x = int(a) y = int(b) z = int(c) print("Number1 = ", x) print("Number2 = ", y) print("Number3 = ", z) # type() function returns the data type print(type(a)) print(type(x))
🌐
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 - Being able to output values in ... easier to look at. ... The built-in int() function takes a float and converts it to an integer, thereby truncating a float value by removing its decimal places....
🌐
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
🌐
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. Two of the most common types to represent numeric ...
🌐
Python
docs.python.org › 3 › library › decimal.html
decimal — Decimal fixed-point and floating-point arithmetic
Construct a new Decimal object based from value. value can be an integer, string, tuple, float, or another Decimal object. If no value is given, returns Decimal('0'). If value is a string, it should conform to the decimal numeric string syntax after leading and trailing whitespace characters, as well as underscores throughout, are removed...
🌐
ItSolutionstuff
itsolutionstuff.com › post › python-remove-all-decimals-from-number-exampleexample.html
Python Remove All Decimals from Number Example - ItSolutionstuff.com
October 30, 2023 - There are several ways to remove all decimals from number in python. i will give you simple one example to remove decimal point from a float.
🌐
Python
docs.python.org › 3.4 › library › decimal.html
9.4. decimal — Decimal fixed point and floating point arithmetic — Python 3.4.10 documentation
These include decimal digits from various other alphabets (for example, Arabic-Indic and Devanāgarī digits) along with the fullwidth digits '\uff10' through '\uff19'. If value is a tuple, it should have three components, a sign (0 for positive or 1 for negative), a tuple of digits, and an integer exponent. For example, Decimal((0, (1, 4, 1, 4), -3)) returns Decimal('1.414'). If value is a float, the binary floating point value is losslessly converted to its exact decimal equivalent.
🌐
Python Guides
pythonguides.com › remove-decimal-numbers-in-python
Remove Decimal Numbers in Python
September 2, 2025 - To remove decimal places in Python, we will pass a float value with a decimal part to this function, which will remove decimal places in Python. We can remove decimal places in Python using the trunc() function from the math library.
🌐
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 - These methods include using the round() function, the astype() function, the apply() function with a lambda function, and the floor() function. By implementing these methods in your code, you can effectively remove decimal points from your data ...
🌐
Enterprise DNA
blog.enterprisedna.co › truncate-float-python
Python Truncate Float: Explained With Examples – Master Data Skills + AI
To truncate float values in Python, you can use the math.trunc() function, decimal module, or string manipulation. Using these techniques, Python developers can tailor the truncation process to their specific requirements with flexibility and precision. In this article, we’ll explore how ...
🌐
Replit
replit.com › home › discover › how to remove the decimal in python
How to remove the decimal in Python | Replit
March 3, 2026 - 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 ...
🌐
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)

🌐
Delft Stack
delftstack.com › home › howto › python › python truncate float python
How to Truncate Float in Python | Delft Stack
February 2, 2024 - The int() function in Python is primarily used to convert other data types, such as strings or floating-point numbers, into integer values. When applied to a floating-point number, it effectively truncates the decimal part, keeping only the ...
🌐
W3Schools
w3schools.com › python › ref_math_trunc.asp
Python math.trunc() Method
# Import math Library import math # Return the truncated integer parts of different numbers print(math.trunc(2.77)) print(math.trunc(8.32)) print(math.trunc(-99.29)) Try it Yourself » · The math.trunc() method returns the truncated integer ...