+ 1
What does int do?
3 Answers
+ 3
int() converts a float or a string to integer.
examples:
int(2.2) will return 2
int(2.9) will return 2
*note that int() will only remove the decimals (not rounding)
You can convert a number inside a string to integer:
int('2') will return 2 as an integer
And finally you can convert a binary, octal, or hexadecimal into integer by passing the appropriate base argument to the int() function:
binary to integer (base 2):
int('10101', 2) will return 21
octal to integer (base 8):
int('25', 8) will return 21
hexadecimal to integer (base 16):
int('15', 16) will return 21
+ 3
it tries to convert its argument to an integer.
+ 1
int represents integer