+ 1

What does int do?

10th Nov 2022, 7:21 PM
jampy
jampy - avatar
3 Respostas
+ 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
10th Nov 2022, 7:46 PM
Mohamed Ghulam
Mohamed Ghulam - avatar
+ 3
it tries to convert its argument to an integer.
10th Nov 2022, 7:31 PM
Lisa
Lisa - avatar
+ 1
int represents integer
11th Nov 2022, 2:16 PM
KAUSHIK T K
KAUSHIK T K - avatar