Types &
Data Structures
Math
Types &
Data Structures II
Math II
Objects & Classes
100

What is list() and what are its arguments?

list(iterable=(), /)

list is a mutable sequence type, not a function

100

What is max() and what are its arguments?

max(iterable, /, *, key=None) max(iterable, /, *, default, key=None) max(arg1, arg2, /, *args, key=None)

Function that returns the largest item in an iterable or the largest of two or more arguments.

100

What is str() and what are its arguments?

class str(*, encoding='utf-8', errors='strict')

class str(object)

class str(object, encoding, errors='strict')

class str(object, *, errors)

str is the built-in string class. str() returns a str version of an object. strs (aka Strings) are immutable sequences of unicode code points.

100

What is float() and what are its arguments?

class float(number=0.0, /)

class float(string, /)

Returns a floating-point number constructed from a number or a string.

100

What is super() and what are its arguments?

class super

class super(type, object_or_type=None, /)

super is a proxy object that delegates method calls to a parent or sibling class of type. This is useful for accessing inherited methods that have been overridden.


class C(B):
    def method(self, arg):
        super().method(arg) # Calls B.method(arg)

200

What is dict() and what are its arguments?

dict(**kwargs)

dict(mapping, /, **kwargs)

dict(iterable, /, **kwargs)

Creates a new dict, which is an instance of the dictionary class. A dictionary is a mapping of key-value pairs.

200
What is sum() and what are its arguments?

sum(iterable, /, start=0)

sum() is a function that sums start and the items of an iterable from left to right and returns the total.

200

What is bool() and what are its arguments?

class bool(object=False, /)

Returns a boolean value (True or False). The argument is converted using the standard truth testing procedure.

200

What is divmod() and what are its arguments?

divmod(a, b, /)

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

200

What is object() and what are its arguments?

class object

This is the ultimate base class of all other classes. It has methods that are common to all instances of Python classes. For example, __init__(), __repr__(), __eq__(), __sizeof__(), etc.

300

What is set() and what are its arguments?

class set(iterable=(), /)

Returns a new set object, optionally with elements from iterable. set is a built-in class.

A set is a mutable, unordered collection of unique elements.

300

What is abs() and what are its arguments?

abs() is a function that returns the absolute value of a number (an integer, floating-point number, or object implementing __abs__()). If the argument is a complex number, its magnitude is returned..

300

What is bin() and what are its arguments?

bin(integer, /)

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

bin(3)
'0b11'

bin(-10)
'-0b1010'

If the prefix “0b” is desired or not, you can use either of the following ways.

format(14, '#b'), format(14, 'b')
('0b1110', '1110')

f'{14:#b}', f'{14:b}'
('0b1110', '1110')

300

What is min() and what are its arguments?

min(iterable, /, *, key=None)

min(iterable, /, *, default, key=None)

min(arg1, arg2, /, *args, key=None)

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

300

What is staticmethod() and what are its arguments?

@staticmethod


staticmethod() is a decorator that transforms a method into a static method. The static method can be called on the class or the instance, but it has no implicit first argument.

Use for utility methods that do not require instance or class data.

Ex:

class C:
    @staticmethod
    def f(arg1, arg2, argN): ...

400

What is tuple() and what are its arguments?

class tuple(iterable=(), /)

tuple is an immutable sequence type, not a function.

400

What is pow() and what are its arguments?

pow(base, exp, mod=None)¶

pow() is a function that returns base to the power exp; if mod is present, return base to the power exp, modulo mod.

400

What is oct() and what are its arguments?

oct(integer, /)

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

oct(8)
'0o10'

oct(-56)
'-0o70'

If you want to convert an integer number to an octal string either with the prefix “0o” or not, you can use either of the following ways.

'%#o' % 10, '%o' % 10
('0o12', '12')

format(10, '#o'), format(10, 'o')
('0o12', '12')

f'{10:#o}', f'{10:o}'
('0o12', '12')

400

What is round() and what are its arguments?

round(number, ndigits=None)

round() is a function that returns number rounded to ndigits precision after the decimal point. If ndigits is omitted or is None, it returns the nearest integer to its input.

400

What is issubclass() and what are its arguments?

issubclass(class, classinfo, /)

issubclass() is a function that returns True if class is a subclass (direct, indirect, or virtual) of classinfo. A class is considered a subclass of itself.

classinfo may be a tuple of class objects or a union type, in which case issubclass() returns True if class is a subclass of any entry in classinfo.

500

What is frozenset() and what are its arguments?

class frozenset(iterable=(), /)

Returns a new frozenset, optionally with elements taken from iterable. frozenset is a built-in class.

Frozensets are immutable and hashable sets.

500

What is int() and what are its arguments?

class int(number=0, /)

class int(string, /, base=10)

int() is a function that returns an integer object constructed from a number or a string, or 0 if no arguments are given.

The string may be expressed in bases other than 10, e.g.

int('FACE', 16)
64206
int('01110011', base=2)
115

If base=0, you must use a prefix like 0b or 0x to specify the base:

int('0xface', 0)
64206

500

What is slice() and what are its arguments?

class slice(stop, /)

class slice(start, stop, step=None, /)

slice() is a function that returns a slice object representing the set of indices specified by range(start, stop, step).

  data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

  # These are equivalent:
  data[2:7]           # [2, 3, 4, 5, 6]
  data[slice(2, 7)]   # [2, 3, 4, 5, 6]

500
What is complex() and what are its arguments?

class complex(number=0, /)

class complex(string, /)

class complex(real=0, imag=0)

Convert a single string or number to a complex number, or create a complex number from real and imaginary parts.

complex('+1.23')
(1.23+0j)

complex('-4.5j')
-4.5j

complex('-1.23+4.5j')
(-1.23+4.5j)

complex('\t( -1.23+4.5J )\n')
(-1.23+4.5j)

complex('-Infinity+NaNj')
(-inf+nanj)

complex(1.23)
(1.23+0j)

complex(imag=-4.5)
-4.5j

complex(-1.23, 4.5)
(-1.23+4.5j)

500

What is classmethod() and what are its arguments?

@classmethod

Transform a method into a class method.

A class method receives the class as an implicit first argument.

class C:
    @classmethod
    def f(cls, arg1, arg2): ...

M
e
n
u