The int() function returns the numeric integer equivalent from a given expression.
int(num.exp)
num.exp | Expression whose numeric integer equivalent is returned. |
This example truncates the decimal and returns the integer portion of the number.
print int(5.1) 5
This example illustrates using the int() function to keep one decimal place and truncate the rest.
x = 10.25 y = int(x*10)/10 print y 10.2