Python Standard Library Functions | Programiz

Python Built-in Functions

Python abs()

returns absolute value of a number

Python any()

Checks if any Element of an Iterable is True

Python all()

returns true when all elements in iterable is true

Python ascii()

Returns String Containing Printable Representation

Python bin()

converts integer to binary string

Python bool()

Converts a Value to Boolean

Python bytearray()

returns array of given byte size

Python callable()

Checks if the Object is Callable

Python bytes()

returns immutable bytes object

Python chr()

Returns a Character (a string) from an Integer

Python compile()

Returns a Python code object

Python classmethod()

returns class method for given function

Python complex()

Creates a Complex Number

Python delattr()

Deletes Attribute From the Object

Python dict()

Creates a Dictionary

Python dir()

Tries to Return Attributes of Object

Python divmod()

Returns a Tuple of Quotient and Remainder

Python enumerate()

returns an enumerated object

Python staticmethod()

transforms a method into a static method

Python filter()

constructs iterator from elements which are true

Python eval()

Runs Python Code Within Program

Python float()

returns floating point number from number, string

Python format()

returns formatted representation of a value

Python frozenset()

returns immutable frozenset object

Python getattr()

returns value of named attribute of an object

Python globals()

returns dictionary of current global symbol table

Python exec()

Executes Dynamically Created Program

Python hasattr()

returns whether object has named attribute

Python help()

Invokes the built-in Help System

Python hex()

Converts to Integer to Hexadecimal

Python hash()

returns hash value of an object

Python input()

reads and returns a line of string

Python id()

Returns Identify of an Object

Python isinstance()

Checks if a Object is an Instance of Class

Python int()

returns integer from a number or string

Python issubclass()

Checks if a Class is Subclass of another Class

Python iter()

returns an iterator

Python list()

creates a list in Python

Python locals()

Returns dictionary of a current local symbol table

Python len()

Returns Length of an Object

Python max()

returns the largest item

Python min()

returns the smallest value

Python map() Function

Applies Function and Returns a List

Python next()

Retrieves next item from the iterator

Python memoryview()

returns memory view of an argument

Python object()

creates a featureless object

Python oct()

returns the octal representation of an integer

Python ord()

returns an integer of the Unicode character

Python open()

Returns a file object

Python pow()

returns the power of a number

Python print()

Prints the Given Object

Python property()

returns the property attribute

Python range() Function

returns a sequence of numbers

Python repr()

returns a printable representation of the object

Python reversed()

returns the reversed iterator of a sequence

Python round()

rounds a number to specified decimals

Python set()

constructs and returns a set

Python setattr()

sets the value of an attribute of an object

Python slice()

returns a slice object

Python sorted()

returns a sorted list from the given iterable

Python str()

returns the string version of the object

Python sum()

Adds items of an Iterable

Python tuple()

Returns a tuple

Python type()

Returns the type of the object

Python vars()

Returns the __dict__ attribute

Python zip()

Returns an iterator of tuples

Python __import__()

Function called by the import statement

Python super()

Returns a proxy object of the base class

Python Dictionary Methods

Python Dictionary clear()

Removes all Items

Python Dictionary copy()

Returns the Shallow Copy of a Dictionary

Python Dictionary fromkeys()

creates dictionary from given sequence

Python Dictionary get()

Returns Value of The Key

Python Dictionary items()

returns view of dictionary's (key, value) pair

Python Dictionary keys()

Returns View Object of All Keys

Python Dictionary popitem()

Returns & Removes Latest Element From Dictionary

Python Dictionary setdefault()

Inserts Key With a Value if Key is not Present

Python Dictionary pop()

removes and returns element having given key

Python Dictionary values()

returns view of all values in dictionary

Python Dictionary update()

Updates the Dictionary

Python List Methods

Python List append()

Add a single element to the end of the list

Python List extend()

adds iterable elements to the end of the list

Python List insert()

insert an element to the list

Python List remove()

Removes item from the list

Python List index()

returns the index of the element in the list

Python List count()

returns count of the element in the list

Python List pop()

Removes element at the given index

Python List reverse()

reverses the list

Python List sort()

sorts elements of a list

Python List copy()

returns a shallow copy of the list

Python List clear()

Removes all Items from the List

Python Set Methods

Python Set remove()

removes the specified element from the set

Python Set add()

adds element to a set

Python Set copy()

Returns Shallow Copy of a Set

Python Set clear()

remove all elements from a set

Python Set difference()

Returns Difference of Two Sets

Python Set difference_update()

Updates Calling Set With Intersection of Sets

Python Set discard()

Removes an Element from The Set

Python Set intersection()

Returns Intersection of Two or More Sets

Python Set intersection_update()

Updates Calling Set With Intersection of Sets

Python Set isdisjoint()

Checks Disjoint Sets

Python Set issubset()

Checks if a Set is Subset of Another Set

Python Set issuperset()

Checks if a Set is Superset of Another Set

Python Set pop()

Removes an Arbitrary Element

Python Set symmetric_difference()

Returns the symmetric difference of sets

Python Set symmetric_difference_update()

Updates the Set with symmetric difference

Python Set union()

Returns the union of sets

Python Set update()

Add elements to the set

Python frozenset()

returns immutable frozenset object

Python String Methods

Python String capitalize()

Converts first character to Capital Letter

Python String center()

Pads string with specified character

Python String casefold()

converts to case folded strings

Python String count()

returns occurrences of substring in string

Python String endswith()

Checks if String Ends with the Specified Suffix

Python String expandtabs()

Replaces Tab character With Spaces

Python String encode()

returns encoded string of given string

Python String find()

Returns the index of first occurrence of substring

Python String format()

formats string into nicer output

Python String index()

Returns Index of Substring

Python String isalnum()

Checks Alphanumeric Character

Python String isalpha()

Checks if All Characters are Alphabets

Python String isdecimal()

Checks Decimal Characters

Python String isdigit()

Checks Digit Characters

Python String isidentifier()

Checks for Valid Identifier

Python String islower()

Checks if all Alphabets in a String are Lowercase

Python String isnumeric()

Checks Numeric Characters

Python String isprintable()

Checks Printable Character

Python String isspace()

Checks Whitespace Characters

Python String istitle()

Checks for Titlecased String

Python String isupper()

returns if all characters are uppercase characters

Python String join()

Returns a Concatenated String

Python String ljust()

returns left-justified string of given width

Python String rjust()

returns right-justified string of given width

Python String lower()

returns lowercased string

Python String upper()

returns uppercased string

Python String swapcase()

swap uppercase characters to lowercase; vice versa

Python String lstrip()

Removes Leading Characters

Python String rstrip()

Removes Trailing Characters

Python String strip()

removes both leading and trailing characters

Python String partition()

Returns a Tuple

Python String maketrans()

returns a translation table

Python String rpartition()

Returns a Tuple

Python String translate()

returns mapped charactered string

Python String replace()

Replaces Substring Inside

Python String rfind()

Returns the Highest Index of Substring

Python String rindex()

Returns Highest Index of Substring

Python String split()

splits string into a list of substrings

Python String rsplit()

Splits String From Right

Python String splitlines()

Splits String at Line Boundaries

Python String startswith()

Checks if String Starts with the Specified String

Python String title()

Returns a Title Cased String

Python String zfill()

Returns a Copy of The String Padded With Zeros

Python String format_map()

Formats the String Using Dictionary

Python Tuple Methods

Python Tuple count()

returns count of the element in the tuple

Python Tuple index()

returns the index of the element in the tuple