We can check the integer part of a real number, and one of the ways to do that is using the trunc() method of the math library.
Let's import the method:
from math import trunc Then we read a real number and display its truncated value on the screen:
n = float(input('Real number: ')) print(f'Integer part: {trunc(n)}') Another way is simply using the int() function to display the value in its entirety.
print(f'Integer part: {int(n)}')
Top comments (0)