List of Commonly used Functions in Python



Type Conversion Functions:


int(): Convert to an integer.

float(): Convert to a floating-point number.

str(): Convert to a string.

list(): Convert to a list.

tuple(): Convert to a tuple.

dict(): Convert to a dictionary.

set(): Convert to a set.



Mathematical Functions:

abs(): Return the absolute value of a number.

max(): Return the maximum value from a sequence.

min(): Return the minimum value from a sequence.

pow(): Calculate the power of a number.

round(): Round a number to a given precision.



String Functions:

len(): Return the length of a string.

str.lower(): Convert a string to lowercase.

str.upper(): Convert a string to uppercase.

str.split(): Split a string into a list based on a separator.

str.join(): Join elements of a list into a single string.



List Functions:

list.append(): Add an element to the end of a list.

list.pop(): Remove and return the last element from a list.

list.extend(): Extend a list by appending elements from another list.

list.index(): Return the index of the first occurrence of an element.

list.sort(): Sort the elements of a list.



Dictionary Functions:

dict.keys(): Return a list of keys in a dictionary.

dict.values(): Return a list of values in a dictionary.

dict.items(): Return a list of key-value pairs as tuples.

dict.get(): Return the value for a given key, or a default value if the key is not found.

dict.update(): Update a dictionary with key-value pairs from another dictionary.



Set Functions:

set.add(): Add an element to a set.

set.remove(): Remove an element from a set.

set.union(): Return the union of two sets.

set.intersection(): Return the intersection of two sets.

set.difference(): Return the difference between two sets.



Input and Output Functions:

print(): Print output to the console.

input(): Read input from the user.



Other Common Functions:

len(): Return the length of an object (list, tuple, string, etc.).

range(): Generate a sequence of numbers.

enumerate(): Return an iterator with index and value pairs.

zip(): Combine multiple iterables element-wise.

sum(): Calculate the sum of elements in a sequence.


Post a Comment

0 Comments