Senior
What built-in data types are available in Python?
sobes.tech AI
Answer from AI
In Python, there are several built-in data types that can be categorized as follows:
- Numeric types:
int(integers),float(floating-point numbers),complex(complex numbers). - Boolean type:
bool(valuesTrueandFalse). - Sequences:
str(strings),list(lists),tuple(tuples),range(number ranges). - Sets:
set(unordered set of unique elements),frozenset(immutable set). - Mappings:
dict(dictionary — key-value pairs). - Others:
bytesandbytearray(for working with binary data),NoneType(type ofNone).
Example of using some types:
x = 10 # int
pi = 3.14 # float
name = "Alice" # str
items = [1, 2, 3] # list
config = {"debug": True} # dict
flag = False # bool