Sobes.tech
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 (values True and False).
  • 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: bytes and bytearray (for working with binary data), NoneType (type of None).

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