• Python
  • Builtins

Python Built-in Functions

global built-in function:

A standalone function available at the top level

Complete List of Python Built-in Functions

Type Conversion and Casting

  • int() – Converts a value to an integer.
  • float() – Converts a value to a floating-point number.
  • complex() – Creates a complex number.
  • str() – Converts a value to a string.
  • bool() – Converts a value to a Boolean.
  • bytes() – Creates an immutable bytes object.
  • bytearray() – Creates a mutable array of bytes.
  • ord() – Converts a character to its Unicode code point.
  • chr() – Converts a Unicode code point to a character.
  • bin() – Converts an integer to a binary string.
  • oct() – Converts an integer to an octal string.
  • hex() – Converts an integer to a hexadecimal string.

Mathematical Operations

  • abs() – Returns the absolute value of a number.
  • divmod() – Returns both the quotient and remainder of a division.
  • pow() – Raises a number to the power of another.
  • round() – Rounds a number to a given number of decimal places.
  • sum() – Returns the sum of elements in an iterable.
  • max() – Returns the largest item in an iterable.
  • min() – Returns the smallest item in an iterable.

Iterators and Loop Helpers

  • iter() – Returns an iterator from an iterable.
  • next() – Retrieves the next item from an iterator.
  • reversed() – Returns a reversed iterator for a sequence.
  • enumerate() – Returns index-value pairs for an iterable.
  • zip() – Combines multiple iterables into a single iterator.
  • filter() – Filters elements from an iterable using a function.
  • map() – Applies a function to all elements of an iterable.

Sequence and Collection Operations

  • len() – Returns the length of an object.
  • list() – Creates a list.
  • tuple() – Creates a tuple.
  • set() – Creates a set.
  • frozenset() – Creates an immutable set.
  • dict() – Creates a dictionary.
  • range() – Generates a sequence of numbers.
  • slice() – Creates a slice object to index a sequence.
  • sorted() – Returns a sorted list from an iterable.

Object Introspection and Attributes

  • type() – Returns the type of an object.
  • id() – Returns the unique identifier of an object.
  • dir() – Lists the attributes of an object.
  • hasattr() – Checks if an object has a specific attribute.
  • getattr() – Retrieves the value of an attribute from an object.
  • setattr() – Sets an attribute on an object.
  • delattr() – Deletes an attribute from an object.
  • callable() – Checks if an object is callable.
  • property() – Creates a managed attribute (property).

Input and Output

  • print() – Outputs data to the console.
  • input() – Reads input from the user.
  • open() – Opens a file for reading or writing.
  • help() – Displays the help text for an object.
  • ascii() – Returns a string with non-ASCII characters escaped.

Functions and Code Handling

  • eval() – Evaluates a string as Python code.
  • exec() – Executes a block of Python code.
  • compile() – Compiles source code into a code object.
  • globals() – Returns the global symbol table as a dictionary.
  • locals() – Returns the local symbol table as a dictionary.
  • __import__() – Dynamically imports a module.

Classes and Object Handling

  • classmethod() – Converts a method to a class method.
  • staticmethod() – Converts a method to a static method.
  • super() – Returns the parent class of an object or class.
  • object() – Returns a new featureless object.

Asynchronous Programming

  • aiter() – Returns an asynchronous iterator.
  • anext() – Retrieves the next item from an asynchronous iterator.

Debugging and Memory Management

  • breakpoint() – Enters a debugger at the calling point.
  • memoryview() – Creates a view of a memory buffer.
  • vars() – Returns the __dict__ attribute of an object.

Logical and Object-Related Functions

  • all() – Returns True if all elements in an iterable are true (or if the iterable is empty).
  • any() – Returns True if any element in an iterable is true; returns False if the iterable is empty or all elements are false.
  • format() – Returns a formatted string according to the specified format.
  • hash() – Returns the hash value of an object (used for quick comparisons, especially in dictionaries).
  • isinstance() – Checks if an object is an instance of a specified class or tuple of classes.
  • issubclass() – Checks if a class is a subclass of another class or tuple of classes.
  • repr() – Returns a string representation of an object that can ideally be used to recreate the object.
Last updated on November 2, 2024