Skip to content

Decimal to int Python | Example code

Use of the built-in int() function to Type conversion Decimal to int in Python. this function trims the values after the decimal point and returns only the integer/whole number part.

int(decimal_value) 

Note: int() function rounds off the result to an integer lesser than or equal to the input.

Decimal to int Python

Simple example code.

num = 100.00
print('type:', num, type(num))

# conversion to int
num = int(num)

print('type:', num, type(num))

Output:

Decimal to int Python

Do comment if you have any doubts or suggestions on this Python conversation code.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

1 thought on “Decimal to int Python | Example code”

  1. 100% wrong.
    Decimal is a class in python, and what you describe is not it.
    In programming, we are either 100% correct, or not.
    This is not correct.

Leave a Reply

Your email address will not be published. Required fields are marked *