2.1 Built-in Types in Python
Python’s standard types are documented in stdtypes. The major families are numeric, sequence, mapping, set, and special singleton/utility types.
Numeric types
int: arbitrary precision integersfloat: double-precision floating-point valuescomplex: complex numbers with.realand.imagbool: subclass ofintwith valuesTrueandFalse
Sequence types
list: mutable ordered collectiontuple: immutable ordered collectionrange: immutable arithmetic progression objectstr: immutable Unicode text sequencebytes,bytearray,memoryview: binary sequence family
Mapping and set types
dict: mutable key/value mapping (keys must be hashable)set: mutable collection of unique hashable elementsfrozenset: immutable set
Truth value testing
Objects are truthy/falsy according to the standard truth-testing rules. Common falsy values include:
FalseNone- numeric zero values
- empty containers (
'',[],{},set(),())
Practical rules from official docs
- Use
list.sort()for in-place sorting andsorted()for new sorted output. - Prefer explicit type conversion (
int(x),float(x),str(x)) when needed. - Avoid relying on
boolbeing anintsubtype for readability.
Official references
- Built-in types: https://docs.python.org/3/library/stdtypes.html
- Built-in functions: https://docs.python.org/3/library/functions.html