Python built-ins Flashcards

1
Q

What does abs() do?

A

returns absolute if a complex number, it returns the magnitude. If x defined __abs__() it returns the result here.

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

all(iterable)

A

returns if all elements in iterable are True

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

ascii(object)

A

returns a string representing an object

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

bin(x)

A

convert to binary with 0b prefixed

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

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

A

create an array of bytes

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

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

A

create an array of bytes

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

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

A

creates byte object

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

callable(object)

A

returns true if callable. Implements __callable__ or a class

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

char(i)

A

returns the unicode char value

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

@classmethod

A

decorator for a class method can be called on an instance

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

compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1)¶

A

compiles to an ast

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

complex([real,[image]])

A

returns a complex number

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

delattr(object,name)

A

deletes an object attribute

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

class dict(**kwarg)

A

builds a dictionary

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

dir([object])

A

without arg returns a list of names in current scope, with arg returns list of valid attribute for an object

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

divmod(a,b)

A

take two non complex numbers and returns division and remainder

17
Q

enumerate

A

iterable that returns a __next__ method that gives a tuple of index and value

18
Q

eval()

A

evaluates a string expression

19
Q

filter(function,iterable)

A

filters an iteable

20
Q

format(value,[format_spec])

A

formats a value according to a spec

21
Q

frozenset([iterable])

A

frozen set

22
Q

getattr(object, name,[default])

A

get an attribute with a possible default

23
Q

globals()

A

return dictionary of global values

24
Q

hasattr(object, name)

A

returns True or False

25
Q

hash([object])

A

returns the hash value of an object if it has one

26
Q

help([object])

A

invokes built-in help system

27
Q

hex(x)

A

converts int to hex

28
Q

id(object)

A

integer guaranteed to be unique during it’s lifetime

29
Q

input([prompt])

A

message with options to read from prompt

30
Q

int(x, base=10)

A

return an integer with a based specified