In this tutorial, we are going to learn about how to remove the decimal part from a number in Python.
When a number having decimal places, we call it a floating-point number in Python.
Consider we have the following number:
num = 8.02
Now we need to remove the decimal places from the above number and print it like this:
To remove the decimal from a number, we can use the
int() method in Python.
int() method takes the number as an argument and returns the integer by removing the decimal part from it.
Here is an example:
num = 8.02; print(int(num));
It can be also used with negative numbers.
num = -9.053; print(int(num));