Built-in Functions Flashcards

Summaries of all built-in functions

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
Q

float([x])

A

Return a floating point number constructed from a number or string x.

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

format(value[, format_spec})

A

Convert a value to a “formatted” representation, as controlled by format_spec.

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

frozenset([iterable})

A

Return a new frozenset object, optionally with elements taken from iterable.

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

getattr(object, name[, default])

A

Return the value of the named attribute of object.

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

globals()

A

Return the dictionary implementing the current module namespace.

30
Q

hasattr(object, name)

A

Returns True if the string is the name of one of the object’s attributes, False if not.

31
Q

hash(object)

A

Return the hash value of the object (if it has one).

32
Q

help([object])

A

Invoke the built-in help system.

33
Q

help([object])

A

Invoke the built-in help system.

34
Q

hex(x)

A

Convert an integer number to a lowercase hexadecimal string prefixed with “0x”

35
Q

id(object)

A

Return the “identity” of an object.

36
Q

input([prompt])

A

Gets console input from the user, reads a line from input, converts it to a string, and returns it.

37
Q

int([x])

int(x, base=10)

A

Returns an integer object constructed from a number or string x, or return 0 if no arguments are given.

38
Q

isinstance(object, classinfo)

A

Return True if the object argument is an instance of the classinfo argument, or of a (direct, indirect, or virtual) subclass thereof.

39
Q

issubclass(class, classinfo)

A

Return True if class is a subclass (direct, indirect, or virtual) of classinfo.

40
Q

iter(object[, sentinel])

A

Return an iterator object.

41
Q

len(s)

A

Return the length (the number of items) of an object.

42
Q

locals()

A

Update and return a dictionary representing the current local symbol table.

43
Q

map(function, iterable, …)

A

Return an iterator that applies function to every item of iterable, yielding the results.

44
Q

max(iterable, *[, key, default])

max(arg1, arg2, *args[,key])

A

Return the largest item in an iterable or the largest of two or more arguments.

45
Q

memoryview(object)

A

Return a “memory view” object created from the given argument.

46
Q

min(iterable, *[, key, default])

min(arg1, arg2, *args[, key])

A

Return the smallest item in an interable or the smallest of two or more arguments.

47
Q

next(iterator[, default])

A

Retrieve the next item from the iterator by calling its __next__() method.

48
Q

object

A

Return a new featureless object.

49
Q

oct(x)

A

Convert an integer number to an octal string prefixed with “0o”.

50
Q

open(file, mode=’r’, buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None)

A

Open file and return a corresponding file object.

51
Q

ord(c)

A

Given a string representing one Unicode character, return an integer representing the Unicode code point of that character.

52
Q

pow(base, exp[, mod])

A

Return base to the power exp.

If mod is present, return base to the power exp, modulo mod.

53
Q

print(*objects, sep=’ ‘, end=’\n’, file=sys.stdout, flush=False)

A

Print objects to teh text stream file, separated by sept and followed by end, sept, end, file, and flush, if present

54
Q

property(fget=None, fset=None, fdel=None, doc=None)

A

Return a property attribute.

55
Q

range(stop)

range(start, stop[, step])

A

Rather than being a function, range is actually an immutable sequence type.

56
Q

repr(object)

A

Return a string containing a printable representation of an object.

57
Q

reversed(seq)

A

Return a reverse iterator.

58
Q

round(number[,ndigits])

A

Return number rounded to ndigits precision after the decimal point.

59
Q

set([iterable])

A

Return a new set object, optionally with elements taken from iterable.

60
Q

setattr(object, name, value)

A

This is the counterpart of getattr() The function assions the value to the attribute.

61
Q

slice(stop)

slice(start, stop[, step])

A

Return a slice object representing the set of indices specified by range(start, stop, step).

62
Q

sorted(iterable, /, *, key=None, reverse=False)

A

Return a new sorted list from the items in iterable.

63
Q

@staticmethod

A

Transform a method into a static method.

64
Q

str(object=’’)

str(object=b’’, encoding=’utf-8’, errors=’strict’)

A

Return a str version of object.

65
Q

sum(iterable, /, start=0)

A

Sums start and the items of an iterable from left to right and returns the total.

66
Q

super([type[, object-or-type]])

A

Return a proxy object that delegates method calls to a parent or sibling class of type.

67
Q

tuple([iterable])

A

Rather than being a function, tuple is actually an immutable sequence type.

68
Q

type(object)

type(name, bases, dict, **kwds)

A

With one argument, return the type of an object.

69
Q

vars([object])

A

Return the __dict__ attribute for a module, class, instance, or any other object with a __dict__ attribute.

70
Q

zip(*iterables, strict=False)

A

Iterate over several iterables in parallel, producing tuples with an item from each one.

71
Q

__import__(name, globals=None, locals=None, fromlist=(), level=0)

A

This function is invoked by the import statement.