The int() function returns the numeric integer equivalent from a given expression.
Syntax
int(num.exp) |
Parameter(s)
num.exp |
Expression whose numeric integer equivalent is returned. |
Example(s)
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 |
See Also