chevron_left
Documentation
Constructor floatConstructor setMethod dirMethod hasattrMethod helpMethod printMethod zipMethod mapMethod enumerateMethod reversedConstructor sliceMethod octMethod typeMethod ordMethod chrConstructor boolMethod asciiMethod anyMethod hexMethod binConstructor strConstructor intConstructor tupleMethod roundMethod nextConstructor rangeMethod inputMethod reprMethod maxMethod minMethod isinstanceConstructor listMethod divmodMethod sumMethod idMethod sortedMethod allMethod lenMethod abs
0
0
0
new
Python | int constructor
Programming
chevron_rightPython
chevron_rightBuilt-in Functions
chevron_rightDocumentation
schedule Mar 10, 2022
Last updated Python
Tags tocTable of Contents
expand_more Python's int(~)
constructor returns an integer object from a string or number.
Parameters
1. x
| number
or string
| optional
The number or string to be converted to an integer object. Defaults to 0.
2. base
| number
| optional
The base-n literal to use when the input is a string. Valid values are 0 and 2 - 36. Default is 10.
Return Value
An integer object.
Examples
Basic usage
To create an integer object from the string '18'
:
Base parameter
To create an integer object from '132'
(expressed in base-5):
'132'
in base-5 is the equivalent to 42
in base-10.
Published by Isshin Inada
Edited by 0 others
Did you find this page useful?
Ask a question or leave a feedback...
Official Python Documentation
https://docs.python.org/3/library/functions.html#int