How to remove decimal part from a number in Python
In this post we will give you information about How to remove decimal part from a number in Python. Hear we will give you detail about How to remove decimal part from a number in PythonAnd how to use it also give you demo for it if it is necessary.
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:
8
Using int() method
To remove the decimal from a number, we can use the int() method in Python.
The 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));
Output:
8
It can be also used with negative numbers.
num = -9.053;print(int(num));
Output:
9
Hope this code and post will helped you for implement How to remove decimal part from a number in Python. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs
