0% found this document useful (0 votes)
16 views2 pages

Python Built-in Functions Overview

The document provides a comprehensive overview of Python's built-in functions and methods for lists, tuples, dictionaries, and strings. It includes descriptions of each function and method, detailing their purpose and usage. This serves as a quick reference guide for Python programming.

Uploaded by

mehtamanjil1508
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Python Built-in Functions Overview

The document provides a comprehensive overview of Python's built-in functions and methods for lists, tuples, dictionaries, and strings. It includes descriptions of each function and method, detailing their purpose and usage. This serves as a quick reference guide for Python programming.

Uploaded by

mehtamanjil1508
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Built-in Functions and Methods

List Functions and Methods

len(list) Built-in Function Returns the number of elements in the list

min(list) Built-in Function Returns the smallest element

max(list) Built-in Function Returns the largest element

sum(list) Built-in Function Returns the sum of all numeric elements

sorted(list) Built-in Function Returns a new sorted list

list(iterable) Built-in Function Converts an iterable into a list

[Link](x) Method Adds element x to the end of the list

[Link](iterable) Method Adds all elements from iterable to the end

[Link](i, x) Method Inserts element x at index i

[Link](x) Method Removes the first occurrence of x

[Link](i) Method Removes and returns item at index i (last by default)

[Link](x) Method Returns index of first occurrence of x

[Link](x) Method Counts how many times x appears in the list

[Link]() Method Sorts the list in place

[Link]() Method Reverses the list in place

Tuple Functions and Methods

len(tuple) Built-in Function Returns the number of elements in the tuple

min(tuple) Built-in Function Returns the smallest element

max(tuple) Built-in Function Returns the largest element

sum(tuple) Built-in Function Returns the sum of all numeric elements

tuple(iterable) Built-in Function Converts an iterable into a tuple

[Link](x) Method Counts how many times x appears in the tuple

[Link](x) Method Returns the index of first occurrence of x

Dictionary Functions and Methods

len(d) Built-in Function Returns number of key-value pairs

dict() Built-in Function Creates a new empty dictionary


Python Built-in Functions and Methods

sorted(d) Built-in Function Returns a sorted list of the dictionary's keys

d[key] Access Returns the value for key; raises error if not found

[Link](key) Method Returns the value or None if key not found

[Link]() Method Returns view of all keys

[Link]() Method Returns view of all values

[Link]() Method Returns view of all (key, value) pairs

[Link](other_dict) Method Adds or updates entries from another dictionary

[Link](key) Method Removes key and returns its value

[Link]() Method Removes all items from the dictionary

[Link]() Method Returns a shallow copy

[Link](k, v) Method Returns key's value; sets it to v if not present

String Functions and Methods

len(str) Built-in Function Returns the number of characters

str() Built-in Function Converts an object to string

[Link]() Method Converts all characters to lowercase

[Link]() Method Converts all characters to uppercase

[Link]() Method Capitalizes first letter of each word

[Link]() Method Removes leading/trailing whitespace

[Link](a, b) Method Replaces all occurrences of a with b

[Link]() Method Splits string into a list by whitespace

[Link](sub) Method Returns index of first occurrence of substring

[Link](sub) Method Counts how many times substring appears

[Link](x) Method Checks if string starts with x

[Link](x) Method Checks if string ends with x

[Link]() Method Checks if all characters are digits

[Link]() Method Checks if all characters are alphabetic

You might also like