105 Must-Know Python
Built-ins, Methods &
Core Statements
A Practical Reference for Writing Clean, Efficient Python
Code
Pooja Pawar
• len() – Returns the number of items in an object
Syntax: len(object)
• type() – Returns the type of an object
Syntax: type(object)
• str() – Converts an object into a string
Syntax: str(object)
• int() – Converts a value into an integer
Syntax: int(value)
• float() – Converts a value into a floating-point
number
Syntax: float(value)
• list() – Converts an iterable into a list
Syntax: list(iterable)
• tuple() – Converts an iterable into a tuple
Syntax: tuple(iterable)
Pooja Pawar
• set() – Creates a set from an iterable
Syntax: set(iterable)
• dict() – Creates a dictionary from key-value pairs
Syntax: dict(mapping or iterable)
• range() – Generates a sequence of numbers
Syntax: range(start, stop, step)
• sorted() – Returns a sorted list from an iterable
Syntax: sorted(iterable, key=None, reverse=False)
• abs() – Returns the absolute value of a number
Syntax: abs(number)
• round() – Rounds a number to specified decimals
Syntax: round(number, ndigits=None)
• sum() – Returns the sum of values in an iterable
Syntax: sum(iterable, start=0)
Pooja Pawar
• min() – Returns the smallest value in an iterable
Syntax: min(iterable)
• max() – Returns the largest value in an iterable
Syntax: max(iterable)
• enumerate() – Returns index and value pairs
Syntax: enumerate(iterable, start=0)
• zip() – Combines multiple iterables element-wise
Syntax: zip(*iterables)
• any() – Returns True if any element is True
Syntax: any(iterable)
• all() – Returns True if all elements are True
Syntax: all(iterable)
• map() – Applies a function to each item
Syntax: map(function, iterable)
Pooja Pawar
• filter() – Filters elements based on a condition
Syntax: filter(function, iterable)
• open() – Opens a file and returns a file object
Syntax: open(file, mode='r')
• read() – Reads content from a file
Syntax: [Link]()
• write() – Writes content to a file
Syntax: [Link](string)
• close() – Closes an open file
Syntax: [Link]()
• help() – Displays documentation for an object
Syntax: help(object)
• dir() – Lists attributes and methods of an object
Syntax: dir(object)
Pooja Pawar
• isinstance() – Checks if an object belongs to a
class
Syntax: isinstance(object, classinfo)
• issubclass() – Checks class inheritance
Syntax: issubclass(class, classinfo)
• getattr() – Gets the value of an attribute
Syntax: getattr(object, name, default)
• setattr() – Sets the value of an attribute
Syntax: setattr(object, name, value)
• hasattr() – Checks if an attribute exists
Syntax: hasattr(object, name)
• delattr() – Deletes an attribute
Syntax: delattr(object, name)
• vars() – Returns the __dict__ of an object
Syntax: vars(object)
Pooja Pawar
• globals() – Returns the global symbol table
Syntax: globals()
• locals() – Returns the local symbol table
Syntax: locals()
• callable() – Checks if an object is callable
Syntax: callable(object)
• format() – Formats a value into a string
Syntax: format(value, format_spec)
• repr() – Returns official string representation
Syntax: repr(object)
• ascii() – Returns ASCII-only representation
Syntax: ascii(object)
• id() – Returns the unique identity of an object
Syntax: id(object)
Pooja Pawar
• chr() – Converts an integer to a character
Syntax: chr(i)
• ord() – Converts a character to its Unicode value
Syntax: ord(c)
• bin() – Converts a number to binary format
Syntax: bin(number)
• oct() – Converts a number to octal format
Syntax: oct(number)
• hex() – Converts a number to hexadecimal
format
Syntax: hex(number)
• hash() – Returns the hash value of an object
Syntax: hash(object)
• slice() – Creates a slice object
Syntax: slice(start, stop, step)
Pooja Pawar
• memoryview() – Accesses memory without
copying
Syntax: memoryview(object)
• compile() – Compiles source code
Syntax: compile(source, filename, mode)
• exec() – Executes dynamically created code
Syntax: exec(object, globals=None, locals=None)
• breakpoint() – Starts the debugger
Syntax: breakpoint()
• super() – Accesses parent class methods
Syntax: super(type, object)
• property() – Manages attribute access
Syntax: property(fget, fset, fdel, doc)
• staticmethod() – Defines a static method
Syntax: staticmethod(function)
Pooja Pawar
• classmethod() – Defines a class method
Syntax: classmethod(function)
• input() – Reads user input from console
Syntax: input(prompt)
• print() – Prints output to console
Syntax: print(objects)
• next() – Returns the next item from an iterator
Syntax: next(iterator)
• iter() – Returns an iterator object
Syntax: iter(iterable)
• frozenset() – Creates an immutable set
Syntax: frozenset(iterable)
• bool() – Converts a value to Boolean
Syntax: bool(value)
Pooja Pawar
• bytes() – Creates an immutable bytes object
Syntax: bytes([source[, encoding[, errors]]])
• bytearray() – Creates a mutable bytes object
Syntax: bytearray(source, encoding, errors)
• object() – Creates a base object
Syntax: object()
• complex() – Creates a complex number
Syntax: complex(real, imag)
• pow() – Returns a number raised to a power
Syntax: pow(base, exp, mod=None)
• divmod() – Returns quotient and remainder
Syntax: divmod(a, b)
• reversed() – Returns a reverse iterator from an
iterable
Syntax: reversed(iterable)
Pooja Pawar
• append() – Adds an item to the end of a list
Syntax: [Link](item)
• extend() – Adds multiple items to a list
Syntax: [Link](iterable)
• insert() – Inserts an item at a given position
Syntax: [Link](index, item)
• remove() – Removes the first matching item
Syntax: [Link](value)
• pop() – Removes and returns an item by index
Syntax: [Link](index=-1)
• get() – Returns a value for a key (safe access)
Syntax: [Link](key, default=None)
• update() – Updates a dictionary with key-value
pairs
Syntax: [Link](mapping)
Pooja Pawar
• assert – Tests a condition during debugging
Syntax: assert condition
• pass – Acts as a placeholder statement
Syntax: pass
• yield – Produces a value from a generator
Syntax: yield value
• raise – Raises an exception
Syntax: raise Exception
• try – Wraps risky code
Syntax: try:
• except – Handles exceptions
Syntax: except Exception:
• finally – Executes cleanup code
Syntax: finally:
Pooja Pawar
• format_map() – Formats a string using a mapping
Syntax: str.format_map(mapping)
• capitalize() – Capitalizes the first character
Syntax: [Link]()
• casefold() – Converts string for case-insensitive
comparison
Syntax: [Link]()
• center() – Centers a string with padding
Syntax: [Link](width)
• count() – Counts occurrences of a substring
Syntax: [Link](substring)
• endswith() – Checks string ending
Syntax: [Link](suffix)
• startswith() – Checks string beginning
Syntax: [Link](prefix)
Pooja Pawar
• find() – Finds first occurrence index
Syntax: [Link](substring)
• index() – Finds index or raises error
Syntax: [Link](substring)
• isalnum() – Checks alphanumeric
Syntax: [Link]()
• isalpha() – Checks alphabetic
Syntax: [Link]()
• isdigit() – Checks numeric
Syntax: [Link]()
• islower() – Checks lowercase
Syntax: [Link]()
• isupper() – Checks uppercase
Syntax: [Link]()
Pooja Pawar
• join() – Joins iterable into a string
Syntax: [Link](iterable)
• lstrip() – Removes leading spaces
Syntax: [Link]()
• rstrip() – Removes trailing spaces
Syntax: [Link]()
• strip() – Removes both-side spaces
Syntax: [Link]()
• replace() – Replaces substring
Syntax: [Link](old, new)
• split() – Splits string into list
Syntax: [Link](separator)
• rsplit() – Splits string from right
Syntax: [Link](separator)
Pooja Pawar
Follow for more
data analytics
content
Pooja Pawar