๐Ÿ Python Built-in Functions – Ultimate Cheat Sheet

Python’s most commonly used built-in functions, organized by alphabet. Each function is explained with a brief description, an example, and some fun ๐ŸŽ‰ emojis to make it easier and more enjoyable to learn.

๐Ÿ”ค A

abs() โ€“ Absolute va…


This content originally appeared on DEV Community and was authored by AK

Python's most commonly used built-in functions, organized by alphabet. Each function is explained with a brief description, an example, and some fun ๐ŸŽ‰ emojis to make it easier and more enjoyable to learn.

๐Ÿ”ค A

abs() โ€“ Absolute value

Returns the absolute value of a number

abs(-7)  # 7

all() โ€“ Checks if all items are True

Returns True if all elements in an iterable are true

all([1, 2, 3])  # True

any() โ€“ Any item True?

Returns True if at least one element is True

any([False, 0, 5])  # True

ascii() โ€“ String representation

Returns a string containing a printable representation

ascii("cafรฉ")  # "'caf\\xe9'"

๐Ÿงฎ B

bin() โ€“ Binary representation

Returns binary version of a number

bin(5)  # '0b101'

bool() โ€“ Boolean value

Converts a value to Boolean (True or False)

bool(0)  # False

bytearray() โ€“ Mutable byte sequence

Creates a mutable array of bytes

bytearray('hello', 'utf-8')  # bytearray(b'hello')

bytes() โ€“ Immutable byte sequence

Creates an immutable bytes object

bytes('hello', 'utf-8')  # b'hello'

๐Ÿ“ž C

chr() โ€“ Character from ASCII

Returns the character corresponding to an ASCII code

chr(65)  # 'A'

complex() โ€“ Complex numbers

Creates a complex number

complex(2, 3)  # (2+3j)

๐Ÿ—‘๏ธ D

delattr() โ€“ Delete attribute

Deletes an attribute from an object

class Car:
    color = "red"
delattr(Car, "color")

dict() โ€“ Dictionary

Creates a dictionary

dict(name="Alice", age=25)  # {'name': 'Alice', 'age': 25}

dir() โ€“ List attributes

Returns list of attributes of an object

dir([])  # Shows list methods like append(), sort(), etc.

divmod() โ€“ Division & Modulus

Returns quotient and remainder

divmod(10, 3)  # (3, 1)

๐Ÿ” E

enumerate() โ€“ Index + Value

Returns index and value pairs

for i, val in enumerate(['a','b','c']): print(i, val)

eval() โ€“ Evaluate expression

Evaluates a string as Python code

eval("2 + 3")  # 5

exec() โ€“ Execute code

Executes a block of Python code

exec("x = 5\nprint(x)")  # 5

๐Ÿงน F

filter() โ€“ Filter items

Filters iterable using a function

list(filter(lambda x: x > 3, [1,2,3,4,5]))  # [4,5]

float() โ€“ Float conversion

Converts a value to float

float("3.14")  # 3.14

format() โ€“ Format values

Formats a string

"{} {}".format("Hello", "World")  # 'Hello World'

frozenset() โ€“ Immutable set

Creates an immutable set

frozenset([1,2,3])  # frozenset({1,2,3})

๐Ÿ’ก G

getattr() โ€“ Get attribute

Returns the value of a named attribute

class Dog: name = "Buddy"
getattr(Dog, "name")  # 'Buddy'

globals() โ€“ Global variables

Returns dictionary of global variables

globals()

๐Ÿ” H

hasattr() โ€“ Check attribute

Returns True if object has that attribute

hasattr(str, "upper")  # True

hash() โ€“ Hash value

Returns hash of an object

hash("hello")  # Some integer

help() โ€“ Documentation

Shows help documentation

help(list)

hex() โ€“ Hexadecimal

Returns hexadecimal representation

hex(255)  # '0xff'

๐Ÿ”ข I

id() โ€“ Identity

Returns memory address of object

id("hello")

input() โ€“ User input

Takes input from user

name = input("Enter name: ")

int() โ€“ Integer conversion

Converts to integer

int("123")  # 123

isinstance() โ€“ Type check

Returns True if object is instance of class

isinstance(5, int)  # True

issubclass() โ€“ Inheritance check

Returns True if class is subclass

issubclass(bool, int)  # True

iter() โ€“ Iterator

Returns iterator object

it = iter([1,2,3])
next(it)  # 1

๐Ÿ“ L

len() โ€“ Length

Returns length of object

len("hello")  # 5

list() โ€“ List

Converts to list

list((1,2,3))  # [1,2,3]

locals() โ€“ Local variables

Returns local variable dict

locals()

๐Ÿ”„ M

map() โ€“ Apply function

Applies function to all items

list(map(lambda x: x.upper(), ["a"]))  # ['A']

max() โ€“ Maximum

Returns maximum value

max([1,2,3])  # 3

min() โ€“ Minimum

Returns minimum value

min([1,2,3])  # 1

memoryview() โ€“ Memory view

Access internal data without copying

mv = memoryview(b'Hello')

โญ๏ธ N

next() โ€“ Next item

Returns next item from iterator

it = iter([1,2])
next(it)  # 1

๐Ÿ“ฆ O

object() โ€“ Base class

Returns a new featureless object

obj = object()

oct() โ€“ Octal

Returns octal representation

oct(8)  # '0o10'

open() โ€“ File opener

Opens a file

with open("file.txt") as f: content = f.read()

ord() โ€“ ASCII code

Returns ASCII code for a character

ord('A')  # 65

๐Ÿ”ฅ P

pow() โ€“ Power

Raises a number to a power

pow(2, 3)  # 8

print() โ€“ Output

Prints output to console

print("Hello!")

property() โ€“ Property

Used in classes to create managed attributes

class Circle:
    def __init__(self, radius):
        self._radius = radius

    @property
    def radius(self):
        return self._radius

๐Ÿ”„ R

range() โ€“ Range of numbers

Generates sequence of numbers

list(range(1, 5))  # [1,2,3,4]

repr() โ€“ Representation

Returns string representation

repr("hello")  # "'hello'"

reversed() โ€“ Reverse iterator

Returns reversed iterator

list(reversed([1,2,3]))  # [3,2,1]

round() โ€“ Round number

Rounds a number to n digits

round(3.1415, 2)  # 3.14

๐Ÿ› ๏ธ S

set() โ€“ Set

Creates a set

set([1,2,2])  # {1,2}

setattr() โ€“ Set attribute

Sets an attribute on an object

class Car: pass
setattr(Car, "color", "blue")

slice() โ€“ Slice object

Represents slicing

s = slice(1, 4)
[0,1,2,3,4][s]  # [1,2,3]

sorted() โ€“ Sort

Returns sorted list

sorted([3,1,2])  # [1,2,3]

staticmethod() โ€“ Static method

Marks a method as static

class Math:
    @staticmethod
    def add(a, b): return a + b

str() โ€“ String

Converts to string

str(123)  # '123'

sum() โ€“ Summation

Adds all items

sum([1,2,3])  # 6

super() โ€“ Parent class

Calls parent class method

class Child(Parent):
    def __init__(self):
        super().__init__()

๐Ÿ“ฆ T

tuple() โ€“ Tuple

Converts to tuple

tuple([1,2])  # (1,2)

type() โ€“ Type

Returns type of object

type(5)  # <class 'int'>

๐Ÿ“ฅ V

vars() โ€“ Object attributes

Returns __dict__ of an object

class Person: pass
p = Person()
vars(p)  # {}

๐Ÿ“ฆ Z

zip() โ€“ Pair items

Pairs items from multiple iterables

list(zip([1,2], ['a','b']))  # [(1,'a'), (2,'b')]

๐Ÿง  Special

__import__() โ€“ Import module

Used by import system internally

math = __import__('math')  # Same as import math

๐Ÿš€ Summary Table

Function Use
abs(), pow(), round() Math operations
str(), int(), float() Type conversion
list(), dict(), set() Data structure creation
map(), filter(), zip() Functional tools
len(), max(), min() Size/value checks
dir(), help(), type() Debugging & introspection


This content originally appeared on DEV Community and was authored by AK


Print Share Comment Cite Upload Translate Updates
APA

AK | Sciencx (2025-05-30T11:50:02+00:00) ๐Ÿ Python Built-in Functions – Ultimate Cheat Sheet. Retrieved from https://www.scien.cx/2025/05/30/%f0%9f%90%8d-python-built-in-functions-ultimate-cheat-sheet/

MLA
" » ๐Ÿ Python Built-in Functions – Ultimate Cheat Sheet." AK | Sciencx - Friday May 30, 2025, https://www.scien.cx/2025/05/30/%f0%9f%90%8d-python-built-in-functions-ultimate-cheat-sheet/
HARVARD
AK | Sciencx Friday May 30, 2025 » ๐Ÿ Python Built-in Functions – Ultimate Cheat Sheet., viewed ,<https://www.scien.cx/2025/05/30/%f0%9f%90%8d-python-built-in-functions-ultimate-cheat-sheet/>
VANCOUVER
AK | Sciencx - » ๐Ÿ Python Built-in Functions – Ultimate Cheat Sheet. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/05/30/%f0%9f%90%8d-python-built-in-functions-ultimate-cheat-sheet/
CHICAGO
" » ๐Ÿ Python Built-in Functions – Ultimate Cheat Sheet." AK | Sciencx - Accessed . https://www.scien.cx/2025/05/30/%f0%9f%90%8d-python-built-in-functions-ultimate-cheat-sheet/
IEEE
" » ๐Ÿ Python Built-in Functions – Ultimate Cheat Sheet." AK | Sciencx [Online]. Available: https://www.scien.cx/2025/05/30/%f0%9f%90%8d-python-built-in-functions-ultimate-cheat-sheet/. [Accessed: ]
rf:citation
» ๐Ÿ Python Built-in Functions – Ultimate Cheat Sheet | AK | Sciencx | https://www.scien.cx/2025/05/30/%f0%9f%90%8d-python-built-in-functions-ultimate-cheat-sheet/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.