Test Series - python

Test Number 91/108

Q: 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
Solution: Functions which are defined at the top level of a module with lambda cannot be pickled.
Q: If __getstate__() returns _______________ the __setstate__() module will not be called on pickling.
A. True value
B. False value
C. ValueError
D. OverflowError
Solution: If getstate__() returns a false value, the __setstate__() module will not be called on pickling.
Q: 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,
Solution: Lambda functions cannot be pickled because all the lambda functions have the same name, that is, 
Q: The module _______________ is a comparatively faster implementation of the pickle module.
A. cPickle
B. nPickle
C. gPickle
D. tPickle
Solution: The module cPickle is a comparatively faster implementation of the pickle module.
Q: The copy module uses the ___________________ protocol for shallow and deep copy.
A. pickle
B. marshal
C. shelve
D. copyreg
Solution: The copy module uses the pickle protocol for shallow and deep copy.
Q: Which module in Python supports regular expressions?
A. re
B. regex
C. pyregex
D. none of the mentioned
Solution: re is a part of the standard library and can be imported using: import re.
Q: Which of the following creates a pattern object?
A. re.create(str)
B. re.regex(str)
C. re.compile(str)
D. re.assemble(str)
Solution: It converts a given string into a pattern object.
Q: What does the function re.match do?
A. matches a pattern at the start of the string
B. matches a pattern at any position in the string
C. such a function does not exist
D. none of the mentioned
Solution: It will look for the pattern at the beginning and return None if it isn’t found.
Q: What does the function re.search do?
A. matches a pattern at the start of the string
B. matches a pattern at any position in the string
C. such a function does not exist
D. none of the mentioned
Solution: It will look for the pattern at any position in the string.

You Have Score    /9