Tech News

Python Cheat Sheet


Python Language Cheat Sheet: Built-In Python Methods With Descriptions

abs()

Returns absolute value of a number
all()
Returns true when all elements in iterable is true
any()
Checks if any element of an Iterable is true
ascii()
Returns a string containing printable representation
bin()
Converts an integer into binary string
bool()
Coverts a value to a boolean value
bytearray()
Returns array of given byte size
bytes()
Returns immutable bytes object
callable()
Checks if an object is callable
chr()
Returns a character (a string) from an Integer
classmethod()
Returns the class method for given function
compile()
Returns a Python code object
complex()
Creates a complex number
delattr()
Deletes an attribute from the object
dict()
Creates a dictionary
dir()
Attempts to return the attributes of an object
divmod()
Returns a tuple of the quotient and remainder
enumerate()
Returns an enumerate object
eval()
Runs Python code within program
exec()
Executes a dynamically created program
filter()
Constructs an iterator from elements which are true
float()
Returns the floating point number from number or string
format()
Returns a formatted representation of a value
frozenset()
Returns an immutable frozenset object
getattr()
Returns the value of a named attribute of an object
globals()
Returns the dictionary of the current global symbol table
hasattr()
Returns whether an object has a named attribute
hash()
Returns the hash value of an object
help()
Invokes the built-in help system
hex()
Converts an integer into a hexadecimal representation
id()
Returns the identity (unique integer) of an object
input()
Reads and returns a line of a string
int()
Returns an integer from a number or string
isinstance()
Checks if an object is an instance of a class
issubclass()
Checks if an object is a subclass of a class
iter()
Returns the iterator for an object
len()
Returns the length of an object
list()
Creates a list in Python
locals()
Returns the dictionary of a current local symbol table
map()
Applies a function and returns a list
max()
Returns the largest element
memoryview()
Returns the memory view of an argument
min()
Returns the smallest element
next()
Retrieves the next element from the iterator
object()
Creates a featureless object
oct()
Converts an integer into an octal representation
open()
Returns a file object
ord()
Returns the Unicode code point for a Unicode character
pow()
Returns x to the power of y
print()
Prints the given object
property()
Returns a property attribute
range()
Returns a sequence of integers between start and stop
repr()
Returns a printable representation of an object
reversed()
Returns the reversed iterator of a sequence
round()
Rounds a floating point number to ndigits places
set()
Returns a Python set
setattr()
Sets the value of an attribute of an object
slice()
Creates a slice object specified by range()
sorted()
Returns a sorted list from a given iterable
staticmethod()
Creates a static method from a function
str()
Returns an informal representation of an object
sum()
Add items of an Iterable
super()
Allows you to refer a parent class by super
tuple()
Creates a tuple
type()
Returns the type of an object
vars()
Returns __dict__ attribute of a class
zip()
Returns an Iterator of tuples
__import__()
Advanced function called by an import statement

No comments:

Post a Comment