bool()
: Convert to boolean (e.g., bool(1)
→ True)int()
: Convert to integer (e.g., int("42")
→ 42)float()
: Convert to float (e.g., float("3.14")
→ 3.14)str()
: Convert to string (e.g., str(42)
→ "42")list()
: Convert to list (e.g., list("abc")
→ ['a', 'b', 'c'])set()
: Convert to set (e.g., set([1, 1, 2])
→ {1, 2})tuple()
: Convert to tuple (e.g., tuple([1, 2, 3])
→ (1, 2, 3))dict()
: Create dictionary (e.g., dict(a=1, b=2)
→ {'a': 1, 'b': 2})bytes()
: Create bytes object (e.g., bytes("hello", "utf-8")
→ b'hello')bytearray()
: Create mutable bytes (e.g., bytearray(b"hello")
→ bytearray(b'hello'))complex()
: Create complex number (e.g., complex(1, 2)
→ (1+2j))bin()
: Convert an integer number to a binary string prefixed with "0b" (e.g., bin(1)
→ 0b1)oct()
: Convert an integer number to an octal string prefixed with "0o" (e.g., oct(1)
→ 0o1)hex()
: Convert an integer number to a lowercase hexadecimal string prefixed with "0x" (e.g., hex(1)
→ 0x1)ord()
: Unicode code point of character (e.g., ord('A')
→ 65)chr()
: Character from Unicode code (e.g., chr(65)
→ 'A')ascii()
: ASCII representation (e.g., ascii('café')
→ 'caf\xe9')repr()
: Printable representation of an object (e.g., repr(f'hello: {var}')
)format()
: Format value (e.g., format(3.14159, '.2f')
→ '3.14')sum()
: Sum of iterable (e.g., sum([1, 2, 3])
→ 6)pow()
: Power function (e.g., pow(2, 3)
→ 8)divmod()
: Division and modulus (e.g., divmod(10, 3)
→ (3, 1))min()
: Minimum value (e.g., min([1, 2, 3])
→ 1)max()
: Maximum value (e.g., max([1, 2, 3])
→ 3)abs()
: Absolute value (e.g., abs(-1)
→ 1)round()
: Round to n digits (e.g., round(3.14159, 2)
→ 3.14)len()
: Length of object (e.g., len([1, 2, 3])
→ 3)range()
: Generate number sequence (e.g., list(range(5))
→ [0, 1, 2, 3, 4])enumerate()
: Add index to iterable (e.g., list(enumerate(['a', 'b']))
→ [(0, 'a'), (1, 'b')])sorted()
: Sort iterable (e.g., sorted([3, 1, 2])
→ [1, 2, 3])reversed()
: Reverse iterator (e.g., list(reversed([1, 2, 3]))
→ [3, 2, 1])zip()
: Combine iterables (e.g., list(zip([1, 2], ['a', 'b']))
→ [(1, 'a'), (2, 'b')])slice()
: Create slice object (e.g., slice(1, 5, 2)
→ start=1, stop=5, step=2 | same as my_array[1:5:2])aiter()
: Returns an async iterator from an async iterable (e.g., aiter(async_iterator())
)anext()
: Gets next item from async iterator (e.g., anext(async_iterator())
)frozenset()
: Creates an immutable set (e.g., frozenset([1, 2, 3, 2])
)map()
: Apply function to iterable (e.g., list(map(str.upper, ['a', 'b']))
→ ['A', 'B'])filter()
: Filter iterable (e.g., list(filter(lambda x: x > 0, [-1, 0, 1, 2]))
→ [1, 2])all()
: True if all elements are true (e.g., all([True, True, False])
→ False)any()
: True if any element is true (e.g., any([False, False, True])
→ True)iter()
: Create iterator (e.g., iter([1, 2, 3])
)next()
: Get next item from iterator (e.g., next(iter([1, 2, 3]))
→ 1)type()
: Get object type (e.g., type(1)
→ <class 'int'>)isinstance()
: Check instance type (e.g., isinstance(1, int)
→ True)issubclass()
: Check subclass relationship (e.g., issubclass(bool, int)
→ True)id()
: Object identity (e.g., id(obj)
)dir()
: List object attributes (e.g., dir(str)
)hasattr()
: Check if object has attribute (e.g., hasattr('hello', 'upper')
→ True)setattr()
: Set attribute value (e.g., setattr(obj, 'name', 'value')
)getattr()
: Get attribute value (e.g., getattr('hello', 'upper')()
→ 'HELLO')delattr()
: Delete attribute (e.g., delattr(obj, 'name')
)vars()
: Returns __dict__ attribute of an object (e.g., vars(obj)
)callable()
: Check if object is callable (e.g., callable(print)
→ True)eval()
: Evaluate expression (e.g., eval('2 + 3')
→ 5)exec()
: Execute code (e.g., exec('x = 5')
)compile()
: Compile source to code object (e.g., compile('x=1', '<string>', 'exec')
)globals()
: Global namespace as a dictionary (e.g., globals()
→ {'g1': 1, 'g2': 2})locals()
: Local namespace as a dictionary (e.g., locals()
→ {'l1': 1, 'l2': 2})hash()
: Hash value of object (e.g., hash('hello')
)memoryview()
: Memory view object (e.g., memoryview(b'hello')
)object()
: Base object (e.g., object()
)property()
: Create property attribute (e.g., @property
)staticmethod()
: Static method decorator (e.g., @staticmethod
)classmethod()
: Class method decorator (e.g., @classmethod
)super()
: Access parent class (e.g., super().__init__()
)print()
: Print to stdout (e.g., print("Hello", "World")
)input()
: Read from stdin (e.g., name = input("Enter name: ")
)open()
: Open file (e.g., open('file.txt', 'r')
)help()
: Interactive help (e.g., help(print)
)breakpoint()
: Debugger breakpoint (e.g., breakpoint()
)__import__()
: Dynamic import (e.g., __import__('math')
)