ReferenceBuilt-in functions
int()
Converts to a whole number, truncating a float towards zero.
Signature
int(value, base=10)Parameters
| Name | Means |
|---|---|
value | a number or a string of digits |
base | the base the text is written in |
Returns
An int. Raises ValueError if the text is not a whole number.
Example
Python
print(int("42"))
print(int(3.9))
print(int(-3.9))
print(int("ff", 16))Output
42 3 -3 255