PRACTICE COLLECTION 2026 SOLUTIONS
GRADED A+
● all(iterable). Answer: Return True if all elements of the iterable are
true (or if the iterable is empty).
● any(iterable). Answer: Return True if any element of the iterable is
true. If the iterable is empty, return False.
● basestring(). Answer: This abstract type is the superclass for str and
unicode. It cannot be called or instantiated, but it can be used to test
whether an object is an instance of str or unicode. isinstance(obj,
basestring) is equivalent to isinstance(obj, (str, unicode)).
● bin(x). Answer: Convert an integer number to a binary string. The
result is a valid Python expression. If x is not a Python int object, it has
to define an __index__() method that returns an integer.
● class bool([x]). Answer: Return a Boolean value, i.e. one of True or
False. x is converted using the standard truth testing procedure. If x is
false or omitted, this returns False; otherwise it returns True. bool is also
a class, which is a subclass of int. Class bool cannot be subclassed
further. Its only instances are False and True.
,● class bytearray([source[, encoding[, errors]]]). Answer: Return a new
array of bytes. The bytearray class is a mutable sequence of integers in
the range 0 <= x < 256. It has most of the usual methods of mutable
sequences, described in Mutable Sequence Types, as well as most
methods that the str type has, see String Methods.
● callable(object). Answer: Return True if the object argument appears
callable, False if not. If this returns true, it is still possible that a call
fails, but if it is false, calling object will never succeed. Note that classes
are callable (calling a class returns a new instance); class instances are
callable if they have a __call__() method.
● chr(i). Answer: Return a string of one character whose ASCII code is
the integer i. For example, chr(97) returns the string 'a'. This is the
inverse of ord(). The argument must be in the range [0..255], inclusive;
ValueError will be raised if i is outside that range. See also unichr().
● classmethod(function). Answer: Return a class method for function. A
class method receives the class as implicit first argument, just like an
instance method receives the instance.
● cmp(x, y). Answer: Compare the two objects x and y and return an
integer according to the outcome. The return value is negative if x < y,
zero if x == y and strictly positive if x > y.
, ● compile(source, filename, mode[, flags[, dont_inherit]]). Answer:
Compile the source into a code or AST object. Code objects can be
executed by an exec statement or evaluated by a call to eval(). source
can either be a Unicode string, a Latin-1 encoded string or an AST
object. Refer to the ast module documentation for information on how to
work with AST objects.
● class complex([real[, imag]]). Answer: Return a complex number
with the value real + imag*1j or convert a string or number to a complex
number. If the first parameter is a string, it will be interpreted as a
complex number and the function must be called without a second
parameter. The second parameter can never be a string. Each argument
may be any numeric type (including complex). If imag is omitted, it
defaults to zero and the function serves as a numeric conversion function
like int(), long() and float(). If both arguments are omitted, returns 0j.
● delattr(object, name). Answer: This is a relative of setattr(). The
arguments are an object and a string. The string must be the name of one
of the object's attributes. The function deletes the named attribute,
provided the object allows it. For example, delattr(x, 'foobar') is
equivalent to del x.foobar.
● class dict(**kwarg) / class dict(mapping, **kwarg) / class
dict(iterable, **kwarg). Answer: Create a new dictionary. The dict object
is the dictionary class. See dict and Mapping Types — dict for
documentation about this class.