Built-in Functions Flashcards

Summaries of all built-in functions (71 cards)

1
Q

abs(x)

A

Return the absolute value of a number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

aiter(async_iterable)

A

Return an asynchronous iterator for an asynchronous iterable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

all(iterable)

A

Return true if all elements of the iterable are true or if the iterable is empty.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

anext(async_iterator[,default])

A

When awaited, return the next item from the given asynchronous iterator, or default if given and the iterator is exhausted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

any(iterable)

A

Return true if any element of the iterable is true. If the iterable is empty, return False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

ascii(object)

A

As repr(), return a string containing a printable representation of an object, but escape the non-ASCII characters in the string returned by repr() using \x, \u, or \U escapes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

bin(x)

A

Convert an integer number to a binary string prefixed with “0b”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

bool([x])

A

Return a boolean value, i.e. one of True or False. x is converted using the standard truth testing procedure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

breakpoint(*args, **kws)

A

Drops you into the debugger at the call site.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

bytearray([source[, encoding[, errors]]])

A

Return a new array of bytes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

bytes([source[, encoding[, errors]]])

A

Return a new “bytes” object which is an immutable sequence of integers in the range 0 <= x < 256.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

callable(object)

A

Return True if the object argument appears callable, False if not.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

chr(i)

A

Return the string representing a character whose Unicode code point is the integer i.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

@classmethod

A

Transform a method into a class method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

compile(source, filename, mode, flags=0, dont_inherit_False, optimize=- 1)

A

Compile the source into a code or AST object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

complex([real[, imag]])

A

Return a complex number with the value real + imag*1j or convert a string or number to a complex number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

delattr(object, name)

A

Deletes the named attribute, provided the object allows it. This is a relative of setattr().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

dict(**kwarg)
dict(mapping, **kwarg)
dict(iterable, **kwarg)

A

Create a new dictionary.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

dir([object])

A

Without arguments, return the list of names in the current local scope. With an argument, attempt to return a list of valid attributes for that object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

divmod(a, b)

A

Take two (non-complex) numbers as arguments and return a pair of numbers consisting of their quotient and remainder when using integer division.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

enumerate(iterable, start=0)

A

Return an enumerate object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

eval(expression[, globals[, locals]])

A

Returns the result of the evaluated expression.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

exec(object[, globals[, locals]])

A

This function supports dynamic execution of Python code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

filter(function, iterable)

A

Construct an iterator from those elements of iterable for which function returns True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
float([x])
Return a floating point number constructed from a number or string x.
26
format(value[, format_spec})
Convert a value to a "formatted" representation, as controlled by format_spec.
27
frozenset([iterable})
Return a new frozenset object, optionally with elements taken from iterable.
28
getattr(object, name[, default])
Return the value of the named attribute of object.
29
globals()
Return the dictionary implementing the current module namespace.
30
hasattr(object, name)
Returns True if the string is the name of one of the object's attributes, False if not.
31
hash(object)
Return the hash value of the object (if it has one).
32
help([object])
Invoke the built-in help system.
33
help([object])
Invoke the built-in help system.
34
hex(x)
Convert an integer number to a lowercase hexadecimal string prefixed with "0x"
35
id(object)
Return the "identity" of an object.
36
input([prompt])
Gets console input from the user, reads a line from input, converts it to a string, and returns it.
37
int([x]) | int(x, base=10)
Returns an integer object constructed from a number or string x, or return 0 if no arguments are given.
38
isinstance(object, classinfo)
Return True if the object argument is an instance of the classinfo argument, or of a (direct, indirect, or virtual) subclass thereof.
39
issubclass(class, classinfo)
Return True if class is a subclass (direct, indirect, or virtual) of classinfo.
40
iter(object[, sentinel])
Return an iterator object.
41
len(s)
Return the length (the number of items) of an object.
42
locals()
Update and return a dictionary representing the current local symbol table.
43
map(function, iterable, ...)
Return an iterator that applies function to every item of iterable, yielding the results.
44
max(iterable, *[, key, default]) | max(arg1, arg2, *args[,key])
Return the largest item in an iterable or the largest of two or more arguments.
45
memoryview(object)
Return a "memory view" object created from the given argument.
46
min(iterable, *[, key, default]) | min(arg1, arg2, *args[, key])
Return the smallest item in an interable or the smallest of two or more arguments.
47
next(iterator[, default])
Retrieve the next item from the iterator by calling its __next__() method.
48
object
Return a new featureless object.
49
oct(x)
Convert an integer number to an octal string prefixed with "0o".
50
open(file, mode='r', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
Open file and return a corresponding file object.
51
ord(c)
Given a string representing one Unicode character, return an integer representing the Unicode code point of that character.
52
pow(base, exp[, mod])
Return base to the power exp. | If mod is present, return base to the power exp, modulo mod.
53
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
Print objects to teh text stream file, separated by sept and followed by end, sept, end, file, and flush, if present
54
property(fget=None, fset=None, fdel=None, doc=None)
Return a property attribute.
55
range(stop) | range(start, stop[, step])
Rather than being a function, range is actually an immutable sequence type.
56
repr(object)
Return a string containing a printable representation of an object.
57
reversed(seq)
Return a reverse iterator.
58
round(number[,ndigits])
Return number rounded to ndigits precision after the decimal point.
59
set([iterable])
Return a new set object, optionally with elements taken from iterable.
60
setattr(object, name, value)
This is the counterpart of getattr() The function assions the value to the attribute.
61
slice(stop) | slice(start, stop[, step])
Return a slice object representing the set of indices specified by range(start, stop, step).
62
sorted(iterable, /, *, key=None, reverse=False)
Return a new sorted list from the items in iterable.
63
@staticmethod
Transform a method into a static method.
64
str(object='') | str(object=b'', encoding='utf-8', errors='strict')
Return a str version of object.
65
sum(iterable, /, start=0)
Sums start and the items of an iterable from left to right and returns the total.
66
super([type[, object-or-type]])
Return a proxy object that delegates method calls to a parent or sibling class of type.
67
tuple([iterable])
Rather than being a function, tuple is actually an immutable sequence type.
68
type(object) | type(name, bases, dict, **kwds)
With one argument, return the type of an object.
69
vars([object])
Return the __dict__ attribute for a module, class, instance, or any other object with a __dict__ attribute.
70
zip(*iterables, strict=False)
Iterate over several iterables in parallel, producing tuples with an item from each one.
71
__import__(name, globals=None, locals=None, fromlist=(), level=0)
This function is invoked by the import statement.