Python Cheatsheet
Explore a collection of 28 of the most commonly used Python functions, including converting strings and integers and math functions.
Prints the specified message to the console or standard output.
print()
Length
Returns the number of items in an object, such as a string, list, or dictionary.
len()
Range
Generates a sequence of numbers within a specified range.
range()
Input
Prompts the user for input and returns a string.
input()
String
Converts a value into a string.
str()
Integer
Converts a value into an integer.
int()
Float
Converts a value into a floating-point number.
float()
List
Creates a new list in Python, which is a collection of items that can be of different data types.
list()
Dictionary
Creates a new dictionary, which is a collection of key-value pairs.
dict()
Tuple
Creates a new tuple, which is an immutable ordered collection of items.
tuple()
Set
Creates a new set, which is an unordered collection of unique items.
set()
Boolean
Converts a value into a Boolean (True or False).
bool()
Type
Returns the type of an object.
type()
Sum
Calculates the sum of a collection of numbers.
sum()
Maximum
Returns the maximum value from a collection of numbers.
max()
Minimum
Returns the minimum value from a collection of numbers.
min()
Absolute Value
Returns the absolute value of a number.
abs()
Round
Rounds a number to the nearest integer or a specified number of decimal places.
round()
Sorted
Returns a new sorted list from the elements of an iterable.
sorted()
Enumerate
Returns a tuple containing the index and value of each element in an iterable.
enumerate()
Any
Returns True if at least one element in an iterable is true, otherwise returns False.
any()
All
Returns True if all elements in an iterable are true, otherwise returns False.
all()
Filter
Constructs an iterator from elements of an iterable for which a function returns true.
filter()
Map
Applies a function to all items in an input list and returns an iterator.
map()
Dir
Returns a list of names in the current local scope or a list of attributes of an object.
dir()
Open File
Opens a file and returns a file object.
open()
Zip
Creates an iterator of tuples by aggregating elements from two or more iterables.
zip()
Unique Identifier
Returns a unique identifier for an object.
id()