Pickle Module Python: MCQs on Pickle Module in Python

Pickle Module Python. MCQs on the topic of Pickle Module in Python Programming.

 

Pickle Module Python

 

 

The copy module uses what protocol for shallow and deep copy ??

a) pickle
b) marshal
c) shelve
d) copyreg

 

The module ______ is a comparatively faster implementation of the pickle module ??

a) cPickle
b) nPickle
c) gPickle
d) tPickle

 

Lambda functions cannot be pickled because ??

a) Lambda functions only deal with binary values, that is, 0 and 1
b) Lambda functions cannot be called directly
c) Lambda functions cannot be identified by the functions of the pickle module
d) All lambda functions have the same name, that is, <lambda>

 

If __getstate__() returns _______________ the __setstate__() module will not be called on pickling ??

a) True value
b) False value
c) ValueError
d) OverflowError

 

Pickle Module Python

 

Which of the following cannot be pickled ??

a) Functions which are defined at the top level of a module with lambda
b) Functions which are defined at the top level of a module with def
c) Built-in functions which are defined at the top level of a module
d) Classes which are defined at the top level of a module

 

The pickle module defines ______ exceptions and exports _______ classes ??

a) 2, 3
b) 3, 4
c) 3, 2
d) 4, 3

 

Which of the following functions raises an error when an unpicklable object is encountered by Pickler ??

a) pickle.PickleError
b) pickle.PicklingError
c) pickle.UnpickleError
d) pickle.UnpicklingError

 

Which of the following functions can accept more than one positional argument ??

a) pickle.dumps
b) pickle.loads
c) pickle.dump
d) pickle.load

 

Pickle Module Python

 

The output of the following two Python codes is exactly the same ??

object
‘a’
CODE 1
>>> pickle.dumps(‘a’, 3)
CODE 2
>>> pickle.dumps(object, 3)

a) True
b) False

 

Which of the following functions can be used to find the protocol version of the pickle module currently being used ??

a) pickle.DEFAULT
b) pickle.CURRENT
c) pickle.CURRENT_PROTOCOL
d) pickle.DEFAULT_PROTOCOL

 

Which of the following Python codes will result in an error ??

object = ‘a’

a) >>> pickle.dumps(object)
b) >>> pickle.dumps(object, 3)
c) >>> pickle.dumps(object, 3, True)
d) >>> pickle.dumps(‘a’, 2)

 

What will be the output of the following Python ??

pickle.HIGHEST_PROTOCOL

a) 4
b) 5
c) 3
d) 6

 

Pickle Module Python

 

Pick the correct statement regarding pickle and marshal modules ??

a) The pickle module supports primarily .pyc files whereas marshal module is used to sterilize Python objects
b) The pickle module keeps track of the objects that have already been sterilized whereas the marshal module does not do this
c) The pickle module cannot be used to sterilize user defined classes and their instances whereas marshal module can be used to perform this task
d) The format of sterilization of the pickle module is not guaranteed to be supported across all versions of Python. The marshal module sterilization is compatible across all the versions of Python

 

To sterilize an object hierarchy which function must be called. To desterilize a data stream which function must be called ??

a) dumps(), undumps()
b) loads(), unloads()
c) loads(), dumps()
d) dumps(), loads()

 

The process of pickling in Python includes ??

a) conversion of a list into a datatable
b) conversion of a byte stream into Python object hierarchy
c) conversion of a Python object hierarchy into byte stream
d) conversion of a data table into a list

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!