Python built-ins Flashcards
What does abs() do?
returns absolute if a complex number, it returns the magnitude. If x defined __abs__() it returns the result here.
all(iterable)
returns if all elements in iterable are True
ascii(object)
returns a string representing an object
bin(x)
convert to binary with 0b prefixed
bytearray([source[, encoding[, errors]]])
create an array of bytes
bytearray([source[, encoding[, errors]]])
create an array of bytes
bytes([source,[encoding,[errors]]])
creates byte object
callable(object)
returns true if callable. Implements __callable__ or a class
char(i)
returns the unicode char value
@classmethod
decorator for a class method can be called on an instance
compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1)¶
compiles to an ast
complex([real,[image]])
returns a complex number
delattr(object,name)
deletes an object attribute
class dict(**kwarg)
builds a dictionary
dir([object])
without arg returns a list of names in current scope, with arg returns list of valid attribute for an object
divmod(a,b)
take two non complex numbers and returns division and remainder
enumerate
iterable that returns a __next__ method that gives a tuple of index and value
eval()
evaluates a string expression
filter(function,iterable)
filters an iteable
format(value,[format_spec])
formats a value according to a spec
frozenset([iterable])
frozen set
getattr(object, name,[default])
get an attribute with a possible default
globals()
return dictionary of global values
hasattr(object, name)
returns True or False
hash([object])
returns the hash value of an object if it has one
help([object])
invokes built-in help system
hex(x)
converts int to hex
id(object)
integer guaranteed to be unique during it’s lifetime
input([prompt])
message with options to read from prompt
int(x, base=10)
return an integer with a based specified