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